That is a cache stampede, sometimes called a thundering herd. Thousands of concurrent requests miss at the same instant and all recompute the same value. Fix it with single flight locking so only one worker recomputes while the others wait or serve stale data. Add jitter to TTLs so keys do not expire together, refresh hot keys in the background before expiry, and serve stale on error.
Why interviewers ask this
This is a favorite because the naive answer (raise the TTL) does not fix anything, it just makes the event rarer and bigger. Interviewers want to see request coalescing, probabilistic early expiry, and stale while revalidate semantics. It also reveals whether you think about correlated failure, which is the underlying theme of most reliability questions.
How to structure your answer
- Name the failure mode and explain why misses correlate in time.
- Give the primary fix: coalesce concurrent recomputations.
- Add TTL jitter and background refresh for hot keys.
- Describe serving stale data as a deliberate degraded mode.
- Mention a negative cache for misses that return nothing.
Example answer
It is a stampede. The key expires, ten thousand in flight requests all miss simultaneously, and they all run the same expensive query, so the database sees ten thousand copies of a query it normally sees once a minute. The first fix is coalescing, so a single flight lock in the cache means one worker recomputes and everyone else waits on that result or gets the stale value. We used a Redis SETNX lock with a short TTL for this and database load on that path dropped by about two orders of magnitude. On top of that I add jitter to every TTL, so instead of exactly 300 seconds it is 300 plus or minus 10%, which decorrelates expiry across keys. For genuinely hot keys I prefer probabilistic early recomputation, where a request near the end of the TTL refreshes in the background while still serving the cached value. And I always cache negative results, otherwise a missing row becomes an unbounded query loop.
Walking into this interview soon? GhostPilot listens to your live call, spots the question the moment it is asked, and puts a structured answer on your screen in real time. Try it on your next mock, or grab a $29 Session Pass, no subscription, for the real thing.
See how it worksFollow-up questions to expect
- How would you implement single flight without a distributed lock?
- What is the risk of serving stale data, and where is it unacceptable?
- How do you handle a cache node dying rather than a key expiring?
Related site reliability engineer questions
Your interviewer will ask their own version of this. Paste your actual job description into the free Question Predictor and get the 20 questions that role is most likely to ask, with what each one is really probing.
Predict my questions