How does Cassandra take so many writes, and why is it so picky about queries?
Some systems write all day and never stop: messages, events, sensor readings. Billions of rows, across data centers, with no single server allowed to be the bottleneck or the point of failure.
Cassandra is a wide-column database built as a ring of equal nodes. There is no primary. The partition key is hashed to a token, the token decides which nodes own the row, and each row is stored on several of them (the replication factor). Each query chooses how many copies must answer: its consistency level.
QUORUM with three replicas, two answers are enough. Memtables flush to immutable SSTable files later, and compaction merges them.For your app: writes stay fast and available even with a node down, if you design tables around your queries.
This page is about a database built for writes spread across many machines, with no primary. I show you where a write goes (commit log, memtable, SSTable), how the partition key decides which machines hold your data, and why deletes and queries the key cannot answer cause most of the trouble. After it you will be able to design a table from its queries, pick a consistency level, and read nodetool's view of the cluster.
A wide-column database: rows grouped into partitions by a key, partitions spread across a ring of equal nodes, every write appended and never updated in place.
Good at: Huge write rates, data that grows forever, several data centres, no single node that must stay up. Time series, messages, event history.
Runs as: one Java process per node; every node is equal; replication per keyspace, consistency per queryA chat app stores messages with PRIMARY KEY (channel_id, sent_at). One channel has 50 million messages, and reads for it are slow on the same few nodes. What is wrong, and what would you change?
Write your answer down first. Then open mine.
What is wrong: the partition key is channel_id alone, so the whole channel is one partition on the same three replicas. At about 300 bytes a message that is roughly 15 GB in one partition: one hot set of nodes, long compactions, and reads that walk a huge partition.
What I would change: add a time bucket, PRIMARY KEY ((channel_id, day), sent_at), or month for quieter channels, so each partition stays well under 100 MB. The app reads the latest bucket first and walks back.
And: old buckets can expire with a TTL and TimeWindow compaction, so retention is files being dropped, not millions of tombstones.
The same mechanism, hot keys and hot partitions, sharding and partitioning, elsewhere on the site: in real incidents, in measurements, and in designs.
Pick an answer. You will see whether it is right, and why.
1. What decides which nodes store a row?
The partition key is hashed to a token, and the token range decides the replicas.
2. Three replicas. You write at QUORUM and read at QUORUM. Does the read see the write?
Two plus two is more than three, so at least one node in the read has the write.
3. What is a tombstone?
Deletes are writes too. The marker stays for gc_grace_seconds so every replica learns about the delete.
4. Why must repair run within gc_grace_seconds?
Once the tombstone is gone, a replica that never saw the delete looks like the newest copy.
How do databases actually work? From one row on disk to transactions: the words you need, PostgreSQL, MySQL and MongoDB from the files up, then Redis, Cassandra and vector search, side by side, and the query and concurrency traps.