We use analytics cookies.We use cookies to analyze site traffic and improve your experience.
Loading...
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”
You're building a messaging platform. Each user has a mailbox. Some users have 10 messages. Power users have 500,000. Each message has different metadata, some have attachments, some have read receipts, some have forwarding chains.
A relational database could handle this, but at the scale of billions of users and trillions of messages, you hit walls. Joins between tables become impossibly expensive. by user requires careful coordination. Schema changes on a multi-petabyte table can take days.
Facebook faced this exact problem in 2008 with their inbox search. They built a system on top of HBase, a column-family store, that could handle their scale. Apple uses Cassandra (another column-family store) to store over 10 petabytes of data powering iCloud services. Netflix, Instagram, and Discord all rely on Cassandra for workloads that relational databases couldn't handle at their scale.
Column-family stores sit in a unique spot: they're not relational databases, they're not simple key-value stores, and despite the name, they're not the same thing as columnar databases. That last point trips people up constantly. Let's clear it up.
A column-family store organizes data into rows and column families, where each row can have different columns within a family. Think of it as a two-dimensional map: the first key is the row key, the second key is the column name, and the value is the cell.
Here's what a user inbox might look like in Cassandra:
Row Key: "user:alice"
Column Family: "messages"
"msg:001" → { from: "bob", body: "Hey!", timestamp: 1711234000 }
"msg:002" → { from: "carol", body: "Meeting at 3pm", timestamp: 1711234100, attachment: "agenda.pdf" }
"msg:003" → { from: "dave", body: "Got it", timestamp: 1711234200 }
Row Key: "user:bob"
Column Family: "messages"
"msg:001" → { from: "alice", body: "Thanks!", timestamp: 1711234300 }
Notice: Alice has 3 messages, Bob has 1. Alice's msg:002 has an attachment field that others don't. This is fine, each row can have different columns. No NULL-filled sparse table like in a relational database.
How this differs from columnar storage:
The "column" in the name refers to the data model (flexible columns per row), not the storage layout.