hardDesignConceptMidSeniorStaff
How do you handle cache invalidation, and what goes wrong at scale?
5 min readUpdated 2026-08-15
Answer
Short answer
Pick a write policy that matches your consistency requirement rather than treating invalidation as an afterthought, then defend against the three failure modes that only appear under load: stampede on expiry, staleness from lost invalidation messages, and unbounded growth from missing eviction.
Was this answer helpful?
Likely follow-ups
- What happens to your system when the cache tier goes down entirely?
- How would you invalidate a key that is derived from five upstream records?
- Why is a very short TTL not a substitute for invalidation?
- How would you detect that your cache is serving stale data in production?
Related questions
- A popular key expires and forty thousand requests reach the database in the same second. What do you change?hardAlso on caching and redis5 min
- What goes into a cache key, and what happens when two requests that should get different responses collide on one?hardAlso on caching6 min
- What problem do virtual threads actually solve, and when do they not help?mediumAlso on scalability5 min
- You need to enforce 100 requests per minute per API key across a fleet of forty servers. Which limiting algorithm, and where does the counter live?hardAlso on redis8 min