AI Hints
Home›System Design Tutorial›Case Study: Autocomplete and Key-Value
System Design · Lesson 111 of 120

A Key-Value Store

Design it yourself.

⏱ 2 min read▶ Video at 2:14:51🎓 Free
Watch this lesson in the System Design courseWatch on YouTube ↗Full System Design course

Our last big case study pulls everything together. Design a distributed key value store, like DynamoDB or Cassandra. Put a value under a key, get it back, at huge scale, without losing data.

A Key-Value Store
From the video: A Key-Value Store
  • Put and get
  • Huge scale
  • Never lose data

Requirements

The API is tiny. Put a key and value, and get a value by key. But the requirements are tough. Store petabytes of data. Stay available, even when machines and networks fail. Keep latency low. And let users choose how consistent reads should be.

keyvalue
APIput(key, value), get(key)
Sizepetabytes
Availabilitysurvive failures
Consistencytunable

The building blocks

We already know the building blocks. Consistent hashing spreads keys across nodes, and makes adding nodes easy. Each key is replicated to several nodes, for safety. And there's no single leader, so any node can accept requests. Next, how those replicas agree.

Consistent hashing ring
Replicas per key
No single leader
The building blocks
From the video: The building blocks

Summary

A distributed key value store uses consistent hashing to spread keys, and replication to survive failures. Next, how reads and writes agree, using quorums.

Key takeaways
  • Tiny API
  • Consistent hashing
  • Replicate every key
Next up: Key-Value Store: Replication — quorum reads and writes