A Key-Value Store
Design it yourself.
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.

- 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.
| key | value |
|---|---|
| API | put(key, value), get(key) |
| Size | petabytes |
| Availability | survive failures |
| Consistency | tunable |
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.

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