</> MAANG.io
system design · 201

Intermediate

Master system design interviews with scalable architecture patterns, distributed systems, and real-world design challenges.

0/124 solved 0% complete

Apache Cassandra

maang.io System Design Series


Apache Cassandra is a masterless, wide-column database built for enormous write volume and always-on availability. It marries Dynamo's distribution (a consistent-hashing ring, leaderless replication, tunable consistency) to Bigtable's storage (the LSM-tree engine). No single point of failure, linear scale by adding nodes, and a consistency dial you turn per query — it's the self-managed cousin of DynamoDB and a system-design interview staple.

This deep dive comes in four parts:

  • Foundations & Core Concepts — the masterless ring, partition keys, and replication factor.
  • Internals — the write path (commit log → memtable → SSTable) and the LSM storage engine, with worked numbers.
  • Advanced Internals — the read path, tunable consistency (R + W > RF), repair, and tombstones.
  • Interview — Staff/Principal Q&A: data modeling, consistency reasoning, and failure handling.

Apache Cassandra — Part 2: Internals & The Write Path

maang.io System Design Series


What is this?

Back to our co-op of corner shops. In Part 1 we saw how the circle decides which shop owns an item. Now zoom into one shop and watch how a good shopkeeper actually handles a delivery. The clever ones don't refile every new item onto the correct dusty shelf the moment it arrives — that's slow. Instead they scribble the delivery in a receiving log (so nothing is ever lost), toss the items into a sorting tray on the counter for instant access, and only later, when the tray is full, do they carry a neatly-sorted batch to the shelves in one efficient trip. Refiling never blocks receiving.

That's exactly how a Cassandra node stores data, and it's why Cassandra writes are astonishingly fast. The trick has a name — the LSM-tree (Log-Structured Merge-tree) — and it's the single most important internal idea in this chapter.

The one-line idea: Cassandra never overwrites data in place. Every write is an append — to a durable log and to a sorted in-memory buffer — and the real filing happens later, in the background, by merging sorted files. Sequential appends are cheap; random in-place updates are expensive; Cassandra simply refuses to do the expensive thing on the hot path.

Let's follow a single write from the moment it lands, then unpack the machinery.


Sign in to continue reading

The rest of this lesson is available with a free account. Signing in with Google or Microsoft is free.

Sign in to read the full lesson

Sign in to MAANG.io

Use your Google or Microsoft account — no password to remember.

Continue with Google Continue with Microsoft

Please accept the terms above to continue.