Code RoomCache stampede protection at scale
HardPrep Room Coding #3434

Cache stampede protection at scale

System designDistributed systemsMid–Senior~35 min

A social feed service caches the rendered timeline for celebrity accounts. One celebrity's cached timeline (a 200KB object, expensive to regenerate — ~800ms, touching 5 backend services) is read 80,000 times per second. When its TTL expires, all 80k concurrent readers miss simultaneously and stampede the regeneration path, melting the backends every TTL cycle. Design stampede protection for this exact scale. Quantify why naive locking isn't enough and describe the mechanism that keeps origin regenerations to roughly one per TTL while keeping reader latency flat.

What a strong answer looks like

Clarify scale and constraints first. Propose a clean component breakdown, then go deep on the hard parts (data model, bottlenecks, consistency, failure modes) and name the trade-offs you are making.

Clarify4:00 left
Estimate4:00 planned
Design11:30 planned
Deep dive9:30 planned
Failure6:00 planned
0:00
Which questions mattered is sealed until you submit. Telling you now would just be handing over the edge cases.