Surl.li inside: how we ensure stability and speed

In the chaos of the internet, it takes just a millisecond for a user to decide whether to stay or close a tab. With this in mind, we designed Surl.li so that every direction would be invisible. To achieve this, we broke the task down into three stages. The first is the web. All short links are served through an Anycast architecture, whereby a single IP address is distributed across dozens of data centres. The browser always connects to the nearest node and, if one region fails, traffic is instantly transferred to another region without the need to change DNS records. The second level is logical. The server's core is written in Go and stores a 'hot' cache of millions of valid links in memory. Reading is performed without accessing the disk and logging is asynchronous, meaning that a standard redirection takes ~12 ms on the server side. During periods of high demand, automation provides horizontal scaling: new containers are set up in 90 seconds and immediately receive the current cache via the gRPC stream. The third layer is monitoring. We send telemetry about every request to ClickHouse, where metrics are analysed in real time. If latency increases by even 5 ms, the orchestrator starts an additional node or resets the cache on cold connections to free up memory. Prometheus controls the entire chain: the SLA is validated at 99.99% by an independent service provider. Thanks to these three layers, the system can withstand flash mobs, ad streams and DDoS waves while remaining invisible to the user. You press a button and it's there.