Design a Distributed Cache

medium
caching
sharding
eviction
availability

Problem brief

A distributed cache keeps frequently read data in memory across a cluster of nodes so that most reads never reach the database. Putting one cache in front of one database is easy. The interview is about what happens at scale: how keys are spread across nodes, what happens when you add or lose a node, how you keep the cache from serving stale data, and how a single expiring key or a single celebrity post can overload the system. The theme running through every answer: the database is sized for the cache's misses, not for the full read traffic, so anything that empties the cache can take the database down.

Practice workspace

Guided practice or a locally saved 45-minute mock.

Step 1 of 12

Functional Requirements

What operations does the cache support, and what would you leave out of version one?

Reference solution hidden

Try answering in the workspace above first. Reveal the full worked solution — data model, architecture, and trade-offs — whenever you want to compare.

Open the full solution page →