Caching medium
A single cache key corresponds to a computationally expensive report. When it expires, 100 concurrent requests miss the cache and attempt to rebuild the report simultaneously, crashing the DB. Ideally, only one builder should run. What is this pattern called?
- A Cache Penetration: A pattern where requests for non-existent keys bypass the cache and hit the database.
- B Split-Brain: A scenario where a network partition causes multiple nodes to believe they are the primary master.
- C Thundering Herd (or Cache Stampede): A condition where concurrent misses for a single key cause redundant DB operations.
- D Write Amplification: A phenomenon where the actual volume of data written to storage is a multiple of the requested write.
Answer: C. Thundering Herd (or Cache Stampede): A condition where concurrent misses for a single key cause redundant DB operations.
The **Thundering Herd** (or Cache Stampede) problem happens when a popular cache key expires and multiple parallel requests try to re-compute the value simultaneously. This wastes partial compute and can overload the DB. Solutions include **Request Coalescing** (collapsing multiple requests into one) or **Locking** (only one builder allowed).
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- In the Cache-Aside pattern, what happens when the application requests data that is missing from the cache (a 'Cache Miss')?
- Why use a centralized Distributed Cache (like a Redis Cluster) over local in-memory caches on each web server?
- Setting a short TTL (e.g., 60 seconds) on a cached object helps to:
- What is the primary architectural goal of introducing a cache into a system?
- Most caching systems rely on the principle of 'Temporal Locality', which states:
- Your cache uses an LRU (Least Recently Used) eviction policy. When the cache is full, which item is removed?