A hot key's TTL expires and thousands of requests miss at once, stampeding the origin — the thundering herd. Watch the origin spike, then tame it with a single-flight lock, jittered TTLs, and stale-while-revalidate that serves slightly old data while one request refreshes.
A hot key (SkyTravel's "Delhi → Mumbai" results) just expired and 20 requests arrive at once. Watch how many actually reach the origin under each strategy.
20 concurrent requests
waiting…
⚡
key expired
🗄️ Origin load0 calls
Bonus — jitter the TTLs. If 10,000 keys are all cached with exactly a 60s TTL, they expire on the same tick and stampede together. Add a small random offset (say 60s ± 10%) and expiries spread out, so the origin never faces a synchronized wall of misses.
What just happened
▹A cache stampede (thundering herd) happens when a hot key expires and many concurrent requests all miss at once — they all hit the origin simultaneously to recompute the same value, often overwhelming it right when it's already busy.
▹Single-flight (request coalescing) lets just one request fetch from the origin while the rest wait for that result — the origin sees one call, not thousands.
▹Stale-while-revalidate serves the slightly-old value immediately to everyone and refreshes once in the background — no user waits and the origin gets one call. And jittering TTLs spreads expiries out so many keys don't all expire on the same tick.