We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
4 system design questions lean on this idea. Each walks through the full answer.
System Design Masterclass · Database Types Storage
Free preview: the first 2 parts of this 8-part lesson.
Already bought the course? Sign in to read the whole lesson.
this lesson is part of
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design courseread the rest of this lesson in
System Design Masterclass
Unlock this lesson and the 751 other paid lessons
$25 once, by PayPal
See the System Design coursein Database Types Storage
This lesson is part of the full System Design Masterclass. Unlock it along with 769 other lessons for a one-time payment.
One-time payment by card or PayPal
Get Lifetime AccessOne-time payment: UPI, card or netbanking
Get Lifetime Access18 Foundation lessons are free, no payment needed. Try them now
It is easy and good
“It is really nice and good Please join the course”
Think about a dictionary. You know the word you're looking up, say, "ephemeral", and you go straight to the E section and find the definition. You don't scan every page from A to Z. You have the key (the word), and you get the value (the definition) in seconds.
Now imagine that dictionary has a billion entries, is distributed across 50 servers around the world, and can answer 10 million lookups per second.
That's a key-value store. And it's the backbone of almost every high-traffic system you've ever used.
Twitter uses key-value stores to cache your timeline. Amazon uses them for shopping cart sessions. Discord uses them for presence (who's online right now). Twitch uses them for live viewer counts. Every time you see data that loads instantly, before the page even finishes rendering, there's probably a key-value store behind it.
A key-value store has exactly one operation contract:
That's it. No schemas. No tables. No columns. No JOINs. No . Just keys and values.
The key is a string. "user:42:session", "product:iphone-15:price", "rate-limit:192.168.1.1". You design your key naming convention to encode meaning.
The value can be almost anything, a string, a number, a JSON blob, a serialized object, or raw binary data. The store doesn't care what the value contains. It's just bytes.
| Feature | Key-Value Store | Relational Database |
|---|---|---|
| Data model | Key -> Value | Tables with rows and columns |
| Query by | Exact key only | Any column, JOINs, aggregations |
| Schema | None | Strict, defined upfront |
| Read speed | Sub-millisecond | Milliseconds to seconds |
| Write speed | Sub-millisecond | Milliseconds |
| Best for | Lookups by known ID | Complex queries, relationships |
The brutal limitation: you can only look up by key. Want to find all users in New York? Can't do it, unless "users-in-new-york" is a key. Want to sort products by price? Not possible. Key-value stores trade query flexibility for raw speed.