Skip to content
Preptima

Caching interview questions

Cache placement, eviction, invalidation, and the stampede and coherence failure modes.

5 questions in System Design.

hard5

hardDesignScenario

A popular key expires and forty thousand requests reach the database in the same second. What do you change?

A cache stampede happens when one hot key expires and every concurrent miss rebuilds the same value. Let one request rebuild while the rest wait or serve stale, then prevent repeats with stale-while-revalidate, jittered TTLs and refresh-before-expiry. Use this caching answer to show the decision, trade-off, and evidence rather than a memorised definition.

5 minmid, senior, staff
hardScenarioDesign

How do you execute a global CDN cache invalidation for a critical security patch without melting your origin servers under a thundering herd?

A cynical look at global cache invalidation, the necessity of origin shielding, and why relying on manual purges is an architectural anti-pattern. Use this distributed systems answer to show the decision, trade-off, and evidence rather than a memorised definition. It also connects caching to the point an interviewer is testing.

3 minsenior, staff
hardDesignConcept

How do you handle cache invalidation, and what goes wrong at scale?

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.

5 minmid, senior, staff
hardDesign

Where do you put the cache, and how big does it need to be?

Choose the layer by who else can reuse the same bytes and how tolerable staleness is that far from the user, then size it from the working set rather than the dataset. Watch the miss rate, not the hit rate: origin load is proportional to misses, so 99 percent falling to 95 is a fivefold traffic increase.

6 minmid, senior, staff