Skip to main content

Cassandra Consistency Levels

Cassandra's most powerful feature is tunable consistency -- you choose per-query how many replicas must participate before an operation is considered successful.

Think first
Cassandra lets you choose consistency per query. If you write with QUORUM and read with ONE, do you get strong consistency? Why or why not?

Write consistency levels

LevelNodes that must acknowledgeTrade-off
ONE / TWO / THREEThe specified countFast, lower durability
QUORUMMajority (N/2 + 1)Balanced -- strong consistency when paired with QUORUM reads
ALLEvery replicaHighest consistency, lowest availability
LOCAL_QUORUMMajority in coordinator's DCStrong consistency within one DC; doesn't wait for remote DCs
EACH_QUORUMMajority in every DCStrongest multi-DC guarantee; highest latency
ANYAt least one node (including hinted handoff)Fastest but weakest -- data may be invisible until hints are delivered

The coordinator contacts all replicas regardless of consistency level. The write is acknowledged when enough confirm. The rest receive the write asynchronously.

Hinted handoff in Cassandra

When a replica is down, the coordinator stores a hint -- the data plus the target node's identity. When the target recovers (detected via gossip), the hint is forwarded. See Hinted Handoff for the general pattern.

Cassandra-specific details:

  • Hints expire after 3 hours (configurable). After that, stale data must be repaired via read repair or nodetool repair.
  • With ANY, a write can succeed by storing only hints -- no replica has the actual data until one recovers.
  • Hint delivery is throttled to prevent overwhelming recovering nodes.
Don't use ANY for critical data

ANY can lose data if the coordinator dies before delivering hints. Use it only for non-critical, high-throughput writes where occasional loss is acceptable.

Read consistency levels

Read consistency mirrors write levels (except EACH_QUORUM, which is too expensive for reads). The coordinator waits for the specified number of replicas before returning data.

Strong consistency formula: R + W > N guarantees every read sees the latest write. Common config: QUORUM reads + QUORUM writes with N=3 gives R=2, W=2 → 2+2 > 3 ✓

The Snitch: routing reads intelligently

The Snitch determines node proximity and latency. For reads, the coordinator uses it to:

  1. Send the full data request to the fastest replica
  2. Send digest requests (checksum only) to other replicas needed for the consistency level

If digests don't match, replicas are out of sync. The coordinator reads full data from all replicas, returns the latest to the client, and triggers read repair.

Think first
During a QUORUM read, the coordinator sends a full data request to one replica and digest requests to others. Why not send full data requests to all replicas?

Read repair in Cassandra

  • At ALL: read repair runs on every read
  • Below ALL: runs probabilistically (10% of reads by default) to limit performance impact
  • Repair is asynchronous -- the client gets its response immediately
Interview angle

Present the R + W > N formula, show how different consistency combinations achieve different guarantees, then mention read repair as the mechanism that gradually fixes inconsistencies. This shows you understand both the theoretical guarantee and the practical repair mechanism.

Quiz
Your cluster has RF=3. You write with consistency level ALL and read with consistency level ONE. A node goes down right after a write is acknowledged. What happens to subsequent reads for that key?