Cache stampede
When many reads miss on the same data at once, each runs the same query, and under heavy load the database can fall before the cache refills — and stay down. Coalesce the misses, keep keys from running out together, warm new nodes, and keep the database standing.
11 minMediumStation: Cache stampedeMembers lesson
Membership isn’t open yet. The free lessons are open — 16 of them.
- Read-through & write-through
- Cache invalidation
- Cache stampede
- Stop the loop
What you'll be able to do
- 1Predict the database load spike when a hot key expires under heavy traffic.
- 2Choose a mitigation: request coalescing, jittered TTLs or early refresh — or a brake (rate limit, circuit breaker, load shedding) in front of the database.
Inside the lesson
- steps
- 10
- questions
- 7
- simulations
- 2
You guess first, then run the system and see if you were right.
Step 1 · The setup
The last stop ended with a flood: empty a cache, and every read goes to the database at once. Pixel's database was roomy enough to ride it out. Suppose Pixel's team had sized the photo database, to save money, for the few misses a warm cache lets through: it can take about 99 reads a second before it's past 95% busy.
At the evening peak, Pixel swaps in a new, empty cache node. Readers ask for 50 popular feeds, 200 reads a second.
Steps 2–10 are for members