← Lessons

quiz vs the machine

Gold1480

System Design

The Key Value Store Design

Building a scalable store of key to value pairs with partitioning and replication.

5 min read · core · beat Gold to climb

The simplest data model

A key value store maps a key to a value, supporting get and put. Its simplicity is the point. With no joins or complex queries, it scales horizontally far more easily than a relational database.

Partitioning

Data is split across nodes by partitioning the keyspace, usually with consistent hashing. Each node owns a slice of keys. This lets the store grow by adding nodes, each taking a share of keys and traffic.

Replication

To survive node failure, each key is replicated to several nodes:

  • A write goes to the owning node and is copied to replicas.
  • A read can be served by any replica.
  • If a node dies, its replicas still hold the data.

Consistency choices

Replication forces a choice. Strong consistency makes every read see the latest write but costs latency and availability. Eventual consistency lets replicas diverge briefly for speed and uptime, converging later. Quorum reads and writes tune this balance.

Key idea

A key value store maps keys to values with get and put, partitions the keyspace across nodes for scale, replicates each key for fault tolerance, and trades strong against eventual consistency.

Check yourself

Answer to earn rating on the learn ladder.

1. Why does a key value store scale more easily than a relational database?

2. Why replicate each key to several nodes?

3. What does eventual consistency trade for speed and uptime?