Preventing Cache Stampedes and Thundering Herds
Learn what a cache stampede is, why it overwhelms your database when a popular key expires, and the locking and refresh techniques that keep your backend safe under load.
What Is a Cache Stampede?
A cache stampede (or thundering herd) happens when a popular cached key expires and many requests miss the cache at the same moment. They all rush to the database to rebuild the value, overwhelming it.
Why It Is So Dangerous
Under high traffic, hundreds or thousands of concurrent misses can hit the database in milliseconds. The backend that normally serves zero load for that key suddenly takes the full firehose, causing latency spikes or outages.
All lessons in this course
- Why Cache? Introduction to Caching
- Implementing Basic Cache Patterns
- Cache Eviction and Expiration
- Preventing Cache Stampedes and Thundering Herds