cache-stampede
Cache stampede and related failures
Four distinct cache failure modes with four distinct fixes. Conflating them leads to applying the wrong remedy.
1. Stampede: thundering herd on expiry
A hot key expires. Before it is repopulated, every concurrent request misses and recomputes the same value. A key served at 1,000 req/s with a 500ms recompute produces about 500 simultaneous identical origin queries at each expiry.
The recompute is then slower because 500 are running, which widens the window and admits more requests. Under enough load this does not recover, which is a metastable failure. See retry-amplification.
Fix A: probabilistic early expiration (XFetch)
The most effective fix and the least known. Each reader independently refreshes slightly early, with probability rising as expiry approaches. No locks and no coordination.
Store the recompute cost alongside the value: