Recall & Review
beginner
What is a cache stampede?
A cache stampede happens when many requests try to get the same data from the cache at the same time, but the data is missing or expired, causing all requests to hit the database simultaneously.
Click to reveal answer
beginner
How does using a lock help prevent cache stampede?
A lock allows only one request to fetch and update the cache while others wait, preventing many requests from hitting the database at once.
Click to reveal answer
intermediate
What is the 'early recomputation' strategy in cache stampede prevention?
Early recomputation means refreshing the cache before it expires, so requests always get fresh data and avoid many cache misses at once.
Click to reveal answer
intermediate
Explain the 'request coalescing' technique.
Request coalescing groups multiple requests for the same missing cache data so only one fetches from the database, and others wait for the result.
Click to reveal answer
intermediate
What Redis feature can be used to implement locking for cache stampede prevention?
Redis supports commands like SET with NX and EX options to create locks that expire automatically, helping to implement distributed locks.
Click to reveal answer
What causes a cache stampede?
✗ Incorrect
A cache stampede happens when many requests miss the cache at the same time and all query the database.
Which Redis command option helps create a lock that only sets if the key does not exist?
✗ Incorrect
SET NX sets the key only if it does not exist, useful for locking.
What is the main benefit of early recomputation in cache management?
✗ Incorrect
Early recomputation refreshes cache before expiry to avoid many misses simultaneously.
Request coalescing means:
✗ Incorrect
Request coalescing groups requests so only one fetches data, reducing load.
Why use locks in cache stampede prevention?
✗ Incorrect
Locks ensure only one request updates cache, preventing many database hits.
Describe what a cache stampede is and why it is a problem.
Think about what happens when many users ask for the same data but the cache is empty.
You got /4 concepts.
Explain two methods to prevent cache stampede using Redis.
Consider how Redis commands can help control access and timing of cache updates.
You got /4 concepts.