How does Cassandra achieve high availability and fault tolerance?
Learn how Cassandra achieves high availability and fault tolerance with its masterless ring, tunable replication, quorum consistency, hinted handoff and repair.
Expected Interview Answer
Cassandra achieves high availability and fault tolerance through a masterless, peer-to-peer ring where every node is equal, combined with tunable data replication that stores copies of each row on multiple nodes so no single failure loses data or stops reads and writes.
Data is partitioned across the ring by a hash of the partition key, and a configurable replication factor places copies on several nodes, spread across racks and datacenters using a topology-aware strategy like NetworkTopologyStrategy. Because there is no master, any node can serve requests, and tunable consistency levels (such as QUORUM or LOCAL_QUORUM) let a quorum of replicas satisfy a request even while others are down. Failed nodes are handled with hinted handoff, read repair, and anti-entropy repair so replicas converge once nodes return.
- No single point of failure — every node is a peer
- Survives node, rack, and full datacenter outages
- Reads and writes continue during partial failures
- Tunable consistency trades latency against durability
- Automatic recovery via hinted handoff and repair
AI Mentor Explanation
Think of a cricket squad where every player can keep wicket, bowl, and bat — there is no single indispensable captain. If one fielder is injured mid-match, another instantly covers that position and the game continues without stopping. Cassandra works the same way: every node is a peer that can serve any request, so losing one player never ends the innings.
Step-by-Step Explanation
Step 1
Partition the data
A hash of the partition key maps each row to a position on the consistent-hashing ring, distributing data evenly across nodes.
Step 2
Replicate copies
The keyspace replication factor places N copies of each partition on distinct nodes, spread by rack and datacenter with NetworkTopologyStrategy.
Step 3
Serve from any node
A client contacts any node as coordinator; because the ring is masterless, no node is a bottleneck or single point of failure.
Step 4
Tune consistency
Consistency levels like QUORUM or LOCAL_QUORUM require only a subset of replicas to respond, so requests succeed while some replicas are down.
Step 5
Heal after failure
Hinted handoff, read repair, and anti-entropy repair reconcile replicas so data converges once failed nodes rejoin the ring.
What Interviewer Expects
- Understanding of the masterless peer-to-peer ring
- Replication factor and replica placement strategies
- Tunable consistency levels and quorum math
- Failure-handling mechanisms: hinted handoff and repair
- Awareness of rack and datacenter awareness for durability
Common Mistakes
- Claiming Cassandra has a master or primary node
- Confusing replication factor with consistency level
- Assuming higher consistency automatically means no availability loss
- Forgetting that replicas should span racks and datacenters
- Ignoring repair and hinted handoff in recovery
Best Answer (HR Friendly)
“Cassandra keeps working even when machines fail because every server is equal and each piece of data is copied onto several servers. If one server goes down, the copies on the others still answer reads and writes, and the system automatically catches the failed server up once it returns.”
Code Example
CREATE KEYSPACE store
WITH replication = {
'class': 'NetworkTopologyStrategy',
'dc1': 3,
'dc2': 3
};
-- read succeeds even if some replicas are down
CONSISTENCY LOCAL_QUORUM;
SELECT * FROM store.orders WHERE order_id = 42;Follow-up Questions
- What is the difference between replication factor and consistency level?
- How does hinted handoff help during a node outage?
- When would you choose QUORUM over LOCAL_QUORUM?
- How does NetworkTopologyStrategy place replicas across racks?
- What is anti-entropy repair and when should you run it?
MCQ Practice
1. What architectural feature makes Cassandra free of a single point of failure?
Every Cassandra node is an equal peer in a ring, so any node can serve requests and no single node's failure stops the cluster.
2. Which mechanism temporarily stores writes for a down replica and delivers them when it recovers?
Hinted handoff has the coordinator hold a hint for an unavailable replica and replays it once the node comes back online.
3. With replication factor 3, a LOCAL_QUORUM read requires responses from how many replicas?
QUORUM equals floor(RF/2)+1, so for RF=3 that is 2 replicas, allowing a read to succeed while one replica is down.
Flash Cards
Is Cassandra master-slave or masterless? — Masterless — every node is an equal peer in a ring, eliminating a single point of failure.
What controls how many copies of data exist? — The replication factor set per keyspace, placed by a replication strategy like NetworkTopologyStrategy.
What is hinted handoff? — The coordinator stores writes destined for a down replica and replays them when the node returns.
Quorum formula? — floor(replication_factor / 2) + 1 replicas must respond to satisfy a QUORUM read or write.