Apache Cassandra

Cassandra Architecture & Ring Topology

Understand how Cassandra's masterless, ring-based architecture achieves scalability and availability.

Cassandra has no master. Every node is equal: any node can accept any read or any write, for any row.

Think of the ring like a group of librarians standing in a circle, each responsible for a specific range of book titles alphabetically — if you ask any librarian for a book, they know exactly which colleague on the circle actually holds it and will pass your request along.

Key Concepts

1
That one decision explains most of what follows — how data is placed, why it stays up when machines die, and what it gives up in return.
2
The ring is a number line joined at the ends. Cassandra hashes the partition key into a token. The full range of possible tokens is split between the nodes:
3
    node A  owns tokens      0 ... 25
    node B  owns tokens     26 ... 50
    node C  owns tokens     51 ... 75
    node D  owns tokens     76 ... 99  (and wraps round to A)
4
Write a row whose key hashes to 63 and it belongs to node C. There is no lookup table and nothing to ask — every node can compute this, because the hash function and the ring layout are known to all of them.
5
Any node can serve you, and becomes the coordinator. The client connects to whichever node it likes. That node hashes the key, works out which nodes hold the data, forwards the request, collects the replies, and answers the client.
6
So the node you talk to is usually not the node holding your data. It is just the one running the errand for this request.
7
Replication walks clockwise. With replication factor 3, the row at token 63 is stored on node C and then the next two nodes round the ring, D and A.
8
Lose node C and the row is still on D and A. Reads and writes carry on, because no single node was ever required.
9
Why nodes own many small ranges, not one big one. With one range each, adding a node means splitting exactly one neighbour's range — that neighbour does all the work of the move while the rest sit idle.
10
So each node owns many scattered small ranges (virtual nodes, 16 per node by default in recent versions). A new node takes a slice from every existing node at once, so the rebuild is spread across the cluster and finishes far sooner.
11
What this design buys, and what it costs. Adding capacity is adding a machine. There is no failover, because there is nothing to fail over to. Writes are fast because any live replica can accept one.
12
The cost is that there is no node that knows the truth. Replicas can disagree, and getting a consistent answer means asking several of them and comparing — which is what consistency levels are for.
13
What the interviewer is probing.1. "How does Cassandra decide which node holds a row?" Probing: the model. Stalls: "A master assigns it." Moves up: the partition key is hashed to a token and the ring position determines the owning nodes — there is no master.
14
2. "What does masterless mean for availability?" Probing: the consequence. Stalls: "Nothing." Moves up: any node can serve any request as a coordinator, so there is no single point of failure and writes continue during node loss.
15
3. "What are virtual nodes for?" Probing: the mechanism. Stalls: "Performance." Moves up: each physical node owns many small token ranges, so adding or removing a node redistributes evenly without manual token assignment.
16
4. "Where does Cassandra sit on CAP?" Probing: the positioning. Stalls: "It is CA." *Moves up:* AP by default with tunable consistency — you choose per query how much consistency to trade for availability.