Design a Cache Invalidation Pipeline for Regional Memcache Clusters
Last updated: November 29, 2026
Quick Overview
Design how Meta keeps look-aside caches in many regions consistent with MySQL after writes, so users do not see stale counts or deleted content served from cache.
Meta
November 29, 20260
0
0 solved
Design how Meta keeps look-aside caches in many regions consistent with MySQL after writes, so users do not see stale counts or deleted content served from cache.
Meta's published memcache work describes invalidations driven from the database commit log, and senior interviews dig into the race conditions. The interviewer checks that you understand why invalidation (delete) beats update, how to order it with replication, and how to stop stale sets.
What the Interviewer Expects
- Explain look-aside caching and why writes delete rather than update
- Drive invalidations from the database commit log
- Order cross-region invalidations after replication
- Prevent stale sets with leases
- Handle invalidation delivery failures
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
- Walk through the race where a stale value gets written back to cache.
- How do you avoid a thundering herd after invalidating a hot key?
- How would you measure cache staleness in production?
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
Goal: after a committed write, every regional cache stops serving the old value within seconds, and no race re-inserts a stale value.
Setup: web servers read from memcache, on miss read MySQL...
High-Level Design
- Writes include cache keys affected (as SQL comments or a side table) in the transaction.
- A commit log tailer on each MySQL replica reads committed transactions, extracts keys, and sends delete...