Design Hot Key Protection for a Shared Memcache Tier
Last updated: November 29, 2026
Quick Overview
Design defenses for a large shared in-memory cache cluster where a few keys (for example a trending YouTube video's metadata) suddenly receive millions of reads per second, overloading the single cache server that owns them.
0
0
0 solved
Design defenses for a large shared in-memory cache cluster where a few keys (for example a trending YouTube video's metadata) suddenly receive millions of reads per second, overloading the single cache server that owns them.
Hot keys are a classic failure mode in Google-scale caching, and this question tests practical, layered fixes. The interviewer looks for detection, replication of hot keys, client-side local caching, and safe handling of the stampede when a hot key expires.
What the Interviewer Expects
- Explain why consistent hashing concentrates hot keys on one server
- Detect hot keys with sampling or sketches
- Replicate hot keys across several servers or add a client-side L1 cache
- Prevent stampedes on expiry with coalescing and early refresh
- Consider consistency impact of extra copies
Key Topics to Cover
How to Approach This
- Start by clarifying functional and non-functional requirements with the interviewer.
- Estimate the scale: QPS, storage, bandwidth. This drives your design decisions.
- Draw a high-level architecture first, then deep dive into 1-2 critical components.
- Discuss trade-offs explicitly (e.g., consistency vs availability, SQL vs NoSQL).
- Address failure scenarios, monitoring, and how the system handles 10x traffic spikes.
Possible Follow-up Questions
- How do you invalidate a key that has been replicated to many places?
- How would you detect a hot key within one second?
- What if a write-heavy key is hot rather than a read-heavy one?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice System Design ProblemsSample Answer
Requirements
- Cluster of thousands of cache servers, keys spread by consistent hashing.
- Normal per-key load is low; a viral event can send millions of reads per second to one key.
- Keep p99 latency low and avo...
High-Level Design
Three layers:
- Detection: each cache server samples requests and maintains a top-k (Space-Saving) of keys; clients also count locally.
- Mitigation in clients: a small in-process L1 cache w...