How Do Consistency Levels Work in Apache Cassandra?
Learn how Cassandra consistency levels like ONE, QUORUM, and ALL balance availability and consistency per query.
Expected Interview Answer
A Cassandra consistency level (like ONE, QUORUM, or ALL) is a per-query setting that determines how many replica nodes must respond before a read or write is considered successful, letting each operation independently choose its point on the availability-versus-consistency spectrum.
Cassandra replicates every row across a configurable number of nodes (the replication factor, RF) determined by the keyspace’s replication strategy. Rather than one fixed cluster-wide guarantee, each read or write request specifies a consistency level: ONE only needs a single replica to respond (fast, less consistent), QUORUM needs a majority of replicas (RF/2 + 1, balancing both), and ALL needs every replica (strongest consistency, least fault-tolerant, since any down replica blocks the operation). Combining QUORUM writes with QUORUM reads guarantees overlap, similar to the general W+R>N pattern, giving strong consistency without requiring every node to be available.
- Tunable per-query trade-off between latency and correctness
- QUORUM read + QUORUM write gives strong consistency without full ALL cost
- ONE maximizes availability and speed for tolerant workloads
- Survives node failures gracefully at lower consistency levels
AI Mentor Explanation
A match result is recorded by three official scorers stationed around the ground (replication factor 3). If the board only requires ONE scorer to confirm the final score before announcing it, results come out instantly but might contradict what the other two scorers wrote if there was a discrepancy. Requiring QUORUM (two of three) balances speed and accuracy, while requiring ALL three means the announcement waits for every scorer, even one stuck in traffic, which is the strongest but slowest guarantee.
Step-by-Step Explanation
Step 1
Set the replication factor
Configure the keyspace’s RF, determining how many nodes hold a copy of each row.
Step 2
Choose the write consistency level
Pick ONE, QUORUM, ALL, or another level for how many replicas must ack a write.
Step 3
Choose the read consistency level
Pick the number of replicas that must respond to a read before returning the latest timestamped value.
Step 4
Balance the two levels
Use QUORUM/QUORUM (or another W+R>RF combination) for strong consistency, or lower levels for maximum availability.
What Interviewer Expects
- Correct explanation of ONE, QUORUM, and ALL and their trade-offs
- Understanding that consistency level is set per query, not cluster-wide
- Knowledge that QUORUM = floor(RF/2) + 1
- Awareness that ALL sacrifices availability since any down replica blocks the request
Common Mistakes
- Assuming Cassandra has a single fixed consistency setting for the whole cluster
- Confusing consistency level with replication factor
- Forgetting ALL reduces fault tolerance to zero for that operation
- Not knowing QUORUM reads plus QUORUM writes gives a strong-consistency guarantee
Best Answer (HR Friendly)
“In Cassandra, every read or write can specify how many of the replica copies must respond before it counts as successful, ranging from just one replica for speed, to a majority (quorum) for balance, to every replica for the strongest guarantee. This lets each query choose its own trade-off between speed, availability, and how up-to-date the data needs to be.”
Code Example
-- Cassandra Query Language (CQL): consistency level set per session/query
CONSISTENCY QUORUM;
INSERT INTO orders (order_id, customer_id, total)
VALUES (1001, 55, 249.99);
-- Write succeeds once a quorum of replicas (e.g. 2 of RF=3) acknowledges it
CONSISTENCY QUORUM;
SELECT * FROM orders WHERE order_id = 1001;
-- Read succeeds once a quorum of replicas responds, guaranteeing
-- overlap with the quorum write above (2 + 2 > 3)Follow-up Questions
- How is QUORUM calculated for a given replication factor?
- What is LOCAL_QUORUM and why is it used in multi-datacenter clusters?
- What happens to a write at consistency level ALL if one replica is down?
- How does Cassandra resolve conflicting values across replicas after the fact?
MCQ Practice
1. With replication factor 3, how many replicas does QUORUM require?
QUORUM is calculated as floor(RF/2) + 1, so for RF=3 that is floor(1.5)+1 = 2 replicas.
2. What is the main downside of using consistency level ALL?
ALL requires every replica to respond, so it has zero fault tolerance for that operation — any down replica blocks it.
3. Which combination gives strong consistency with RF=3?
QUORUM writes and QUORUM reads (2 and 2 with RF=3) sum to more than RF, guaranteeing the read overlaps the write.
Flash Cards
What is a Cassandra consistency level? — A per-query setting for how many replicas must respond before a read or write succeeds.
How is QUORUM calculated? — floor(replication factor / 2) + 1.
What is the trade-off of consistency level ALL? — Strongest consistency but zero fault tolerance — any unavailable replica fails the request.
What gives strong consistency in Cassandra? — Using QUORUM (or higher) for both reads and writes so the quorums always overlap.