Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 12

Design a distributed key-value store

Advanced · 45 min · Distributed infrastructure

Internal teams want a shared store for session data, shopping carts and user preferences: put a value under a key, get it back fast, and never be told "unavailable" because one machine died. You are building the store itself, not an application on top of one.

Requirements

  • get(key), put(key, value) and delete(key) with values up to 1 MB.
  • Spread data across many nodes and add or remove nodes without downtime.
  • Keep every value on several nodes in different availability zones.
  • Let callers choose, per request, between faster and more consistent reads and writes.

Constraints and assumptions

  • 100 TB of data after 3 years; keys up to 256 bytes, values average 2 KB.
  • Peak 500,000 reads/s and 100,000 writes/s across the cluster.
  • p99 under 10 ms for single-key operations within a region.
  • Three availability zones; the store must keep accepting writes if any single zone is cut off or lost.
  • Commodity nodes: assume one node can serve roughly 20,000 operations per second and hold about 4 TB comfortably.

Out of scope for the first sketch

Multi-key transactions · Secondary indexes and range queries · Cross-region replication

Draw your design

Rough math and notes

Done on paper? Compare with the worked approaches