.NET Architecture & System Design Interview Question #34
What is a cache stampede?
Caching, CDN, Queues & Asynchronous Processing Junior Beginner
Quick Interview Answer
A cache stampede occurs when many requests simultaneously discover that a popular cache entry is missing or expired and all perform the same expensive operation against the backing system.
Detailed Explanation
A cache stampede occurs when many requests simultaneously discover that a popular cache entry is missing or expired and all perform the same expensive operation against the backing system.
Mitigations include request coalescing or locking, refreshing before expiration, adding expiration jitter, stale-while-revalidate techniques, and protecting the backing service with rate or concurrency limits.
Code Example
100 requests
|
same cache miss
X
Only one request loads data
|
others wait/use stale value