Caching interview question · Most asked
Explain the difference between cache penetration, cache breakdown and cache avalanche.
Summary
Penetration: requests for data that doesn't exist bypass the cache every time. Breakdown (stampede): one hot key expires and many requests rebuild it at once. Avalanche: many keys (or the whole cache) disappear at once and the database takes all the load.
Longer Answer
Fixes differ: negative caching and Bloom filters for penetration; request coalescing, locks, early refresh or stale-while-revalidate for breakdown; TTL jitter, bounded database fallback, replication/persistence and warming for avalanches.
Key Points
- Penetration: missing keys
- Breakdown: one hot key expires
- Avalanche: mass loss/expiry
- Different protections for each
Deep dive: Database Caching at Scale
More most-asked Caching questions
- Explain the main caching patterns: cache-aside, read-through, write-through and write-behind.
- Why is cache invalidation hard, and what strategies help?
- What is a cache stampede (thundering herd) and how do you prevent it?
- How does HTTP caching work (Cache-Control, ETag, CDNs)?
- In cache-aside, why can a value be stale even though you delete the key on every write?
- How can a CDN leak one user's data to another, and how do you prevent it?
- In a system design interview, how do you decide what and where to cache?
- How does stale-while-revalidate work, and when is it inappropriate?