Projects / Chat store / Wrap up
Wrap up
Keep going
- A real cluster. Start three containers and set
replication_factorto 3. Stop one and see which levels still work. - Paging. Use the driver in your language to read a big partition a page at a time.
- Compaction. Read how
SizeTieredCompactionStrategyandTimeWindowCompactionStrategydiffer, and why time-window fits messages. - A materialized view. Look at why Cassandra's own views are still marked experimental in many guides, and what teams use instead.
What this version leaves out, and what a real system does
- We run one node with one copy. A cluster has many nodes and several copies, and most of what makes Cassandra interesting happens between them: repair, hinted handoff, gossip.
- Our batch keeps two tables in step only for writes that go through it. A real application needs the same care on every path, deletes included, as Phase 4 showed.
- Real chat apps cap the size of a partition and plan bucket sizes from message rates, not from a guess.
- Lightweight transactions are slow, and heavy use of them is a design smell.
- We did not touch security. Real clusters turn on authentication and encryption.
Check yourself
Answer each question in your head first, then open it to check.
What decides which machine holds a row, and what decides the order of rows inside the partition?
The partition key is hashed into a token, which decides the machine. The clustering key sorts the rows inside the partition.Why did the query in Step 1.5 fail, and why is that better than letting it run?
The query did not name a partition, so it could not use the layout and would have to scan every partition. Failing early tells you the table does not fit the question, before a big table makes it slow.Why store the same message in two tables?
Each table is laid out for one question, so each question is a read of one partition. Copies cost disk, which is cheap, and save scans, which are expensive.What is the point of a day bucket in the partition key?
It caps the size of a partition. Without a bucket, a busy room would grow one partition without limit.How did two tables end up disagreeing in Phase 4, and how would you prevent it?
We deleted from one table and not the other. Writing both deletes in one batch, and keeping all writes behind one function, prevents it. A periodic check like the one in Step 4.2 finds what slips through.Teach it back: explain to a teammate what a tombstone is and why
gc_grace_secondsexists.A tombstone is a marker that says a value was deleted, because files cannot be changed in place. It has to be kept forgc_grace_secondsso that a copy of the data that was offline during the delete cannot bring the row back.