What Is a Key-Value Store?
Why this matters: this chapter is the one place in the course where you design a real distributed system end to end. Every mechanism in it — consistent hashing, quorums, vector clocks, gossip — reappears inside other designs for the rest of your career.
Key takeaway
Key-value stores are distributed hash tables (DHTs). A unique key, generated by a hash function, binds to a specific value, and the store remains agnostic to the value's structure. Values can be blobs, images, server names, or any user-defined data.
What goes in it
Values should generally be small — kilobytes to megabytes. For large datasets, store the content in a blob store and keep only a link to it in the value field.
The store never inspects the value. That opacity is the source of both its simplicity and its speed: there is no schema to validate, no query to plan, and no index to maintain — just hash the key and fetch.
Why web-scale companies use them
Scaling traditional databases with strong consistency and high availability is challenging in distributed environments. Many services — Amazon, Facebook, Netflix — use primary-key access instead of traditional online transaction processing (OLTP) databases.
Common use cases:
| Use case | Why key-value fits |
|---|---|
| Shopping carts | Keyed by user or session; must always accept a write |
| Session management | Pure lookup by session ID at enormous rate |
| Customer preferences | Small, per-user, no cross-record queries |
| Bestseller lists and sales rank | Precomputed values fetched by a single identifier |
| Product catalogs | Read-dominated lookups by product key |
What this chapter builds
The design divides into four stages, each solving one problem the previous stage created:
- Design a key-value store — define requirements and the API.
- Ensure scalability and replication — achieve scalability with consistent hashing, then replicate the partitioned data.
- Versioning data and achieving configurability — resolve conflicts from concurrent updates and make the system tunable.
- Enable fault tolerance and failure detection — survive failures and notice when they happen.
Key takeaway
A key-value store trades the query power of a database for scale, availability, and simplicity. It is the right tool when your access pattern is "fetch this one thing by its identifier" — which describes far more of the internet than people expect.
Interview signal by level
| Level | What a strong answer sounds like |
|---|---|
| L4 | "A key-value store maps keys to values, like a hash table." |
| L5 | Knows the fit: "sessions and carts are pure lookup by ID, so a key-value store — no need for a relational engine." |
| Staff+ | Frames it as a distributed system: "it's a DHT — the interesting parts aren't get and put, they're how keys map to nodes as the cluster changes, and what happens to a write during a partition." |
Next: pinning down exactly what we're building.