How regional origin shields cut our cold-cache latency by 38%
About 98.7% of the images we serve come straight from an edge cache. This post is about the other 1.3% — the requests where an edge location has never seen a variant before and has to go and get it.
The old path
Until January, a cache miss at any of our edge locations went directly to a render node in the region where the customer’s originals were stored. For a shop with originals in Frankfurt and a visitor in Sydney, that meant a long round trip, a render, and a long trip back. Worse, when a new product launched, forty edge locations could each ask for the same variant within the same second.
Adding a middle tier
We now run a shield cache in five regions: Frankfurt, Virginia, São Paulo, Singapore and Sydney. Each edge location is assigned to the nearest shield, and only shields talk to render nodes.
Request collapsing
The shield is where concurrent misses for the same variant get merged. The first request takes a short lock keyed on the variant’s hash; anyone else waiting for the same key subscribes to its result instead of triggering a second render. During a large customer’s seasonal launch in January, this turned 31,000 near-simultaneous misses into 740 renders.
Results
- p50 latency for edge misses: 212 ms → 131 ms (−38%).
- p99 latency for edge misses: 1.9 s → 0.84 s.
- Render-node CPU during launch peaks: down 61%.
- Egress from customer-owned buckets: down 44%, which several customers noticed on their own storage bills.
What we’d do differently
We initially assigned edges to shields by geography alone. Network distance turned out to matter more — two of our Asian edge locations had better paths to Sydney than to Singapore. Assignments are now recalculated weekly from measured round-trip times.
The change is live for every plan at no extra cost. Scale customers can additionally request a dedicated shield in a fixed region.