Apache Cassandra

Consistency Levels (ONE, QUORUM, ALL, LOCAL_QUORUM)

Understand how consistency levels let developers tune the trade-off between consistency, availability, and latency per query.

Cassandra lets each individual query choose how many replicas must answer before it counts as done. That choice is the consistency level.

It's like requiring a certain number of witnesses to sign off before you trust a fact is true — ALL requires everyone in the room to agree, ONE just needs a single person's word, and QUORUM needs a majority vote.

Key Concepts

1
It is set per query, so one statement can be fast and loose and the next strict.
2
The levels you need. With replication factor 3:
3
    ONE            1 replica must respond          fastest, may be stale
    QUORUM         2 of 3 must respond             majority across all datacentres
    LOCAL_QUORUM   2 of 3 in the local datacentre  majority, no cross-DC wait
    ALL            3 of 3 must respond             any node down = query fails
4
A quorum is floor(RF/2) + 1, so 2 of 3, or 3 of 5.
floor(RF/2) + 1
5
The rule that makes reads correct. If reads and writes together touch more replicas than exist, they must share at least one:
6
    R + W > RF
7
With RF=3, write at QUORUM (2) and read at QUORUM (2): 2 + 2 = 4 > 3. Line up the nodes and see why:
8
    write went to   A  B  .
    read asks       .  B  C
                       ^ B is in both, and B has the new value
9
Four slots over three nodes means one node is used twice. That node holds the latest write, Cassandra compares the timestamps it gets back, and the newest wins. The read cannot miss it.
10
Now write at ONE and read at ONE: 1 + 1 = 2, which is not greater than 3. The write went to A and the read asks C. No overlap, so you read stale data — not through a fault, but by arithmetic.
11
Why ALL is worse than it sounds. Requiring all three replicas means one node being down, or slow, fails the query. You have given up the availability you chose Cassandra for. QUORUM gives you the same correctness while tolerating one dead replica.
12
Why LOCAL_QUORUM is the production default in a multi-datacentre cluster. Plain QUORUM counts replicas everywhere, so a cluster in Mumbai and Virginia has to wait for a round trip across an ocean — a fixed 200 ms or so on every write.
13
LOCAL_QUORUM requires a majority inside the local datacentre only. Cross-DC replication still happens, just not on the critical path.
LOCAL_QUORUM
14
Mixing them deliberately. Writing at QUORUM and reading at ONE gives fast reads that are usually current but not guaranteed. That is the right trade for a view counter and the wrong one for an account balance. The level is a per-query decision because the right answer differs per query.
15
What the interviewer is probing.1. "What guarantees strong consistency?" Probing: the formula. Stalls: "Using ALL." *Moves up:* R + W > RF — quorum reads with quorum writes satisfies it without the availability cost of ALL.
16
2. "Why is LOCAL_QUORUM the usual choice multi-datacentre?" Probing: the practical answer. Stalls: "It is faster." Moves up: it avoids cross-datacentre latency on every operation while still giving a quorum within the local one.
17
3. "What does consistency level ONE give you?" Probing: the trade. Stalls: "Speed." *Moves up:* lowest latency and highest availability, with the possibility of reading stale data.
18
4. "Why is ALL discouraged?" Probing: the availability cost. Stalls: "It is slow." *Moves up:* a single unavailable replica fails the operation, which removes the fault tolerance Cassandra exists to provide.