Design a Distributed Cache (Memcache), stage 9 of 9: defend it
Defend 'best-effort eventual consistency'
Your interviewer: "Your cache can serve stale data in at least four ways. Why not a strongly consistent cache, or write-through updates, and be done with it?"
System so far· 7 parts
Select a component to see what it is responsible for and which state it owns.
- 1Users → Web servers: Page request
- 2Web servers → mcrouter: get / multiget, delete
- 3mcrouter → memcached pool: Keys by consistent hash
- 4Web servers → MySQL: Query on miss; writes
- 5MySQL → Invalidation daemon: Committed deletes
- 6Invalidation daemon → mcrouter: Batched deletes
- 7mcrouter → Gutter pool: On server failure
- Request / response
- Bulk data
- Asynchronous
What you need to know
0 of 1 checks done
"Eventually consistent" is too vague to defend. A strong answer lists:
- Specific guarantees: for example, a writer sees their own write; a stale value can't be cached after a newer write.
- Specific windows of staleness: where they come from and what bounds each one.
- What stronger consistency would cost: usually coordination on the hot path.
- Where you'd choose differently: data that can't tolerate any staleness.
Check
What would strong consistency for every read cost a cache serving billions of reads a second across regions?