Design a distributed cache like Redis
A distributed cache (Redis Cluster/Memcached) spreads an in-memory key-value store across many nodes with replication and failover. The interesting parts are partitioning (consistent hashing), replication, and eviction.
Infrastructure, 10 components, about 40 min
The full guide covers requirements, estimates, the API, the data model, deep dives, trade-offs, failure modes and the follow-up questions interviewers ask.
Read the full guide on SubstackKey points
- Consistent hashing with virtual nodes (~150/server) → smooth rebalancing.
- Each shard: 1 primary + 2 replicas; async replication.
- Eviction: LRU with approximate sampling (Redis maxmemory-policy).
- TTL via lazy + active expiration; expired keys swept by background thread.
- Failover: Sentinel/Cluster manager promotes replica on heartbeat loss.
Sign in to track this guide in your curriculum progress.