How we achieved sub-50ms global latency with edge caching
A deep dive into our multi-tier caching architecture, anycast routing, and the engineering decisions that keep P95 latency below 50ms across 200+ locations.
Sub-50ms P95 latency globally sounds like a marketing claim. Here's the engineering behind it — what we actually built, the decisions that didn't work, and the architecture we landed on.
The baseline problem
Speed of light is the fundamental constraint. Light travels roughly 200km per millisecond through fiber. A request from Singapore to a server in Frankfurt covers about 10,000km — which means the theoretical minimum round-trip is ~50ms before you've done any work. In practice, with routing overhead, TCP handshakes, and TLS negotiation, a cold request from Singapore to a European origin takes 180–250ms.
The only way to get latency below 50ms globally is to serve from infrastructure that's physically close to every user. That means edge nodes, and it means caching aggressively at those nodes.
Tier 1: Edge nodes
We operate 200+ edge nodes across six continents, colocated in major internet exchange points. Each edge node runs a caching layer with a local NVMe store. For a cached asset, the request never leaves the edge — the response comes entirely from local storage.
Edge cache hit rates for static assets (images, video, JS/CSS) run above 92% in steady state. For a cache hit, P95 latency is under 12ms from any major metro. The 50ms target only matters when we miss cache.
Tier 2: Regional shields
On a cache miss at the edge, a naive architecture would send the request all the way back to the origin. We added a middle tier: regional shield nodes that sit between the edges and the origin. Each shield serves a cluster of 10–15 edge nodes.
A cache miss at the edge becomes a cache hit at the shield roughly 70% of the time. The shield-to-edge distance is much shorter than origin-to-edge — typically under 20ms. This is the biggest single contributor to our P95 improvement: turning most long-haul misses into short regional hops.
Anycast routing
We use anycast for CDN traffic: multiple nodes advertise the same IP prefix via BGP, and the internet automatically routes each user to the nearest node. This means we don't maintain a geolocation database — the network itself does the routing.
Anycast has edge cases (literal). Nodes near political or geographic borders sometimes attract traffic from the wrong region due to BGP path asymmetry. We monitor per-PoP latency continuously and override anycast with geolocation-based DNS for specific prefixes where anycast routing consistently produces suboptimal results.
Cache key design
A common mistake is caching at the URL level. If your images are served with query parameters for transformations (?w=800&q=80), you end up with a separate cache entry for every parameter combination — and hit rates collapse.
We normalise cache keys: sort query parameters, strip irrelevant headers, and collapse equivalent parameter combinations. An asset requested as ?w=800&q=80 and as ?q=80&w=800 maps to the same cache key. This roughly doubled our edge hit rate when we deployed it.
What we got wrong
Our first attempt at the shield tier used HTTP/1.1 between edge and shield. Under high concurrency, head-of-line blocking caused latency spikes at the 99th percentile even when the median was fine. Switching to HTTP/2 multiplexing on the edge-to-shield path dropped P99 by 40%.
We also underestimated the impact of TLS session resumption. Cold TLS handshakes between tiers added 10–15ms per miss. Implementing TLS session tickets on all internal paths removed that overhead entirely.
Current numbers
P50 latency for cached assets: 8ms globally. P95: 42ms. P99: 78ms. Cache hit rate (edge): 92.4%. Cache hit rate (edge + shield): 98.1%. Origin request rate: under 2% of total traffic.
These numbers hold in steady state. Cold starts — new assets with no cache entries anywhere — still involve origin fetches, but the warming time is fast enough that most users after the first never see origin latency.
More Engineering articles
← All articlesStart hosting files the simple way
Create a workspace, upload your first asset and copy its CDN URL. The free plan includes 3 GB of storage and 15 GB of transfer.
No credit card required · Cancel anytime