medium

Design a Distributed Cache

Design a distributed caching service that applications use to offload repeated reads from slower backing stores (SQL databases, object stores, external APIs). Clients issue GET, SET, and DEL operations on keys with optional TTLs, and the cache spreads keys across many nodes so a single cluster can serve workloads that no single machine can hold in memory. The service should survive node failures, rebalance when nodes are added or removed, and evict data gracefully when memory fills up.

Suggested time: 60 minutes

Loading the workspace...

About this problem

A distributed cache looks like a simple key-value store on the surface. Clients call GET, SET, and DEL, the service responds quickly, and everyone goes home happy. The actual design is harder than it looks because the cache sits directly on the hot path of every other system, and when it misbehaves it takes down the systems that depend on it. Forget that distinction and you will design a database, not a cache.

What your design needs to cover

  • Key-value operations

  • Automatic sharding

  • Replication for availability

  • Eviction under memory pressure

  • Cluster membership

  • Hot-key and stampede mitigation

Key challenges the editorial covers

Learn from other designs

Concepts used in this design

The building blocks this design relies on, each explained in its own lesson.

Related problems

Guides