Design Thundering Herd Protection for a Viral Post's Cache Key
Last updated: November 29, 2026
Quick Overview
Design how Meta's caching layer keeps a viral Facebook post (its content, counters and comments preview) from overwhelming the database when its cache entry expires or is invalidated while millions of users are reading it.
Meta
November 29, 20260
0
0 solved
Design how Meta's caching layer keeps a viral Facebook post (its content, counters and comments preview) from overwhelming the database when its cache entry expires or is invalidated while millions of users are reading it.
Celebrity and breaking-news posts create extreme hot keys at Meta, and the classic failure is a cache miss that sends thousands of concurrent fills to one database shard. The interviewer checks techniques like lease-based fill coordination, stale-while-revalidate, hot key replication, and local caching.
What the Interviewer Expects
- Explain the thundering herd and why it is dangerous for one shard
- Use leases so only one client fills on miss
- Serve stale data briefly while revalidating
- Detect hot keys and replicate or cache them locally
- Handle invalidation storms on frequently updated hot posts
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
- What if the post is being edited and liked thousands of times per second?
- How would you detect a hot key automatically?
- What is the cost of serving stale content here?
- How does this interact with cross-region replication?
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
Scenario: a post from an account with 100M followers gets 2 million reads per minute. Its object lives in one memcache server (by key hash) and one MySQL shard. When the key is invalidated (an edi...
High-Level Design
Three layers. (1) Lease-based fill in memcache: on miss, the first client gets a lease token and fills; others get a "hot miss" response and either wait briefly and retry, or receive the stale val...