Replication and Consistency

Part 2 deliberately pretended each range had one owner. It doesn't — every range is replicated RF times, and that's what keeps a node failure boring. This part is about what replication costs you in exchange: replicas drift, and the mechanisms that pull them back together (quorum overlap, hinted handoff, read repair) each fix a different subset of the drift and leave the rest to a manual nodetool repair. The single most important idea here is that R + W > N is not a transaction — it makes reads fresh without making writes safe.

Replication Factor and Topology

Replication factor (RF) is the number of copies Cassandra maintains for every piece of data. RF=3 means each row exists on 3 different nodes.

RF is set per keyspace — Cassandra's term for a logical database or namespace — not per table.

CREATE KEYSPACE my_app
  WITH replication = {
    'class': 'NetworkTopologyStrategy',
    'us-east': 3,
    'eu-west': 2
  };

Topology Hierarchy: Node, Rack, Datacenter

Cassandra's topology is a strict hierarchy: Data Center → Rack → Node.

NodeOne running instance of the database process — one machine or VM. Owns a range of tokens and stores data on local disk. The smallest unit of topology.
RackA logical grouping of nodes, typically mapped to a physical rack — shared power, shared top-of-rack switch. Racks matter because everything in one tends to fail together.
Data centerA group of racks — usually a distinct facility or cloud region. Used for geographic distribution, workload isolation (analytics vs. live traffic), and disaster recovery.

Cassandra uses this hierarchy directly in replica placement: RF is specified per datacenter, and within a DC, replicas are spread across racks — so a single node, rack, or DC failure never takes out every copy at once.

The keyspace from the CREATE KEYSPACE statement, placed. Datacenter us-east has RF 3: three racks, one replica node in each. Datacenter eu-west has RF 2: two racks, one replica node in each. Writes replicate between the two datacenters asynchronously. Because there is one replica per rack, no single rack, and no single datacenter, holds every copy.
The keyspace above, placed — one replica per rack, in each datacenter

Replica Placement Strategies

The placement strategy controls which nodes receive the replicas.

StrategyHow it places replicasUse it when
SimpleStrategyThe next N nodes clockwise on the ring, ignoring rack and datacenter topology entirelySingle-datacenter development clusters. Never production.
NetworkTopologyStrategyRF specified per datacenter; within each DC, replicas are placed on nodes in different racksAlways, in production. With RF=3 and 3 racks, each replica lands in a different rack, so a full rack failure still leaves 2 complete copies.
  • Guarantees: RF distinct nodes hold every row, chosen to spread across racks and datacenters according to the declared topology.
  • Does not guarantee: That those nodes are on genuinely independent hardware. Placement is only as good as the labels, and nothing validates them against reality.

R + W > N, Explained Simply

The setup: a row has N copies. When you write, you wait for W of them to confirm. When you read, you ask R of them and go with what they say.

The question the formula answers: how do I pick R and W so a read is guaranteed to see the most recent write?

R + W > N

Two panels, N equals 3 in both. Left: W 2 and R 2, so R plus W is 4, greater than 3. The write touches A and B, the read touches B and C; B is touched by both, so the read cannot miss the write. Right: W 1 and R 1, so R plus W is 2, not greater than 3. The write touches only A and the read only C; no replica is shared, so the read can miss the write entirely.
If R + W > N the read set and write set must share a replica — that is the whole guarantee

Concrete example: N=3 replicas (A, B, C), with W=2 and R=2.

  • A write might succeed on A and B.
  • A read might query B and C.
  • Even though the read never asked A, it asked B — and B has the new value. Guaranteed overlap, guaranteed fresh read.

If instead R=1 and W=1 (R+W = 2, not > N = 3), the write could land only on A while the read only checks C. No overlap, stale read possible.

Consistency Levels in These Terms

Cassandra has no setting called "W = 2". Instead, every query gets a named consistency level, and Cassandra turns that name into a number of replicas. That number is your W (on a write) or your R (on a read).

Step 1: what each name means. With 3 copies of every row (RF = 3):

You put in the queryCassandra waits for
ONE1 replica
QUORUMa majority, which is 2 of 3 (the rule is floor(RF/2)+1)
ALLall 3 replicas
LOCAL_QUORUMa majority of the copies in your own datacenter: 2 of that DC's 3

Step 2: add the write number and the read number. A read is guaranteed to see the latest write only if the two numbers add up to more than 3:

Write levelRead levelW + RFresh read guaranteed?
ONE (1)ONE (1)2✗ No. They can hit different replicas.
ONE (1)ALL (3)4✓ Yes, but every read needs all 3 nodes up
QUORUM (2)QUORUM (2)4✓ Yes. This is the standard choice.
ALL (3)anything (1+)4+✓ Yes, but one node down and the write fails

The datacenter catch. LOCAL_QUORUM only counts replicas in the datacenter you're talking to. Suppose you have two datacenters, DC1 and DC2, each with 3 copies:

  • Write in DC1, read in DC1: 2 + 2 > 3 inside DC1, so the read is fresh ✓
  • Write in DC1, read in DC2: DC2 gets the write later, in the background. The read might be stale ✗

Consistency levels are just names for R and W. Pick a write level and a read level whose numbers add up to more than RF. In practice that means QUORUM + QUORUM, or LOCAL_QUORUM + LOCAL_QUORUM when the write and the read happen in the same datacenter.

Nothing Above Happens by Default

The overlap guarantee only applies if you ask for it by choosing levels like QUORUM. If you don't choose anything, you get the weakest setting:

DataStax drivers default toLOCAL_ONE: ask 1 replica in your datacenter
cqlsh defaults toONE: ask 1 replica

So out of the box, every write waits for 1 replica and every read asks 1 replica. That's 1 + 1 = 2, which is not more than 3. The read and the write can hit different replicas, and the read can come back stale.

Why not always use QUORUM? Because it costs you something. You choose the level per query, so pick based on what each query needs:

ONE / LOCAL_ONEQUORUM (RF=3)
Replicas it waits for12
SpeedFast: the quickest replica answersSlower: it waits for the second replica, so one slow node slows the query down
Still works with…2 of 3 nodes down1 of 3 nodes down. Lose a second one and queries fail.
Across datacentersStays in your datacenterMay wait on another datacenter (LOCAL_QUORUM doesn't)

ONE is the right choice when slightly old data is fine and speed matters: analytics, cache refills, view counters. The mistake isn't using ONE. It's using ONE and assuming reads are always fresh.

Most production apps use LOCAL_QUORUM for both writes and reads. You get fresh reads inside your datacenter without waiting on a far-away one. Plain QUORUM would give fresh reads across all datacenters, but then every query waits on a round trip to another region.

"Contacted" Means Something Different for Reads and Writes

That table says QUORUM at RF=3 needs 2 replicas. True for both reads and writes — but the number of nodes the coordinator actually talks to differs, and that difference decides what happens when a replica is unhealthy.

Write @ QUORUM, RF=3sends to all 3, returns as soon as 2 ack
Read @ QUORUM, RF=3sends to exactly 2, needs both to answer

Writes are broadcast because a mutation is small and idempotent — sending a third copy costs almost nothing and the redundancy is free insurance. Reads are not: a data response can be megabytes, so contacting replicas you don't need would waste bandwidth on every single query.

Digest Reads: Why Two Replicas Isn't Two Copies of the Data

At QUORUM the coordinator (the node that received your query) needs answers from 2 replicas. But the two copies are almost always identical, so getting the full rows from both would waste bandwidth. Instead, only one replica sends the real data and the other sends a fingerprint:

  1. The fastest replica sends the full data. Cassandra keeps track of how quickly each replica has answered lately; this tracker is called the dynamic snitch. A node that's slow right now (busy compacting, stuck in a garbage-collection pause, on a slow disk) scores worse. The coordinator asks the best-scoring replica for the actual rows.
  2. The other replica sends only a fingerprint. It runs the same query but returns a digest: a short hash of the result, a few bytes instead of the whole payload.
  3. Fingerprints match: both copies agree, so the coordinator returns the data it already has. This is what happens almost every time.
  4. Fingerprints don't match: one copy is out of date. Only then does the coordinator fetch the full data from the other replica too, keep the version with the newest timestamp, and fix the stale copy (read repair, §5).

So a normal QUORUM read sends one copy of the data plus one tiny hash over the network, not two copies. It's also how Cassandra notices that replicas disagree in the first place: read repair in §5 starts from a fingerprint mismatch.

Speculative Retry: What Saves a Read When a Replica Goes Quiet

Asking only 2 replicas saves bandwidth, but there's a catch. The coordinator needs both answers, and no backup request is already on its way. If one of the two is slow, or has died and nobody has noticed yet, the read just sits there waiting.

Speculative retry is the fix: if a replica takes longer than usual to answer, the coordinator sends the same request to the third replica, the one it didn't ask.

What "longer than usual" means. Each table has a speculative_retry setting. The default is 99PERCENTILE: if a replica is slower than 99% of this table's recent reads, try another one. That kicks in after a few milliseconds, long before the 5-second timeout. The third replica answers, the coordinator has its 2 responses, and the client sees a slightly slow read instead of an error.

That's why losing a node usually shows up on dashboards as a brief p99 latency spike, not a wave of failed reads.

If a replica is dead and…What happens to the QUORUM read
…it wasn't one of the 2 askedNothing. Normal speed, correct answer.
…it was asked, and a third replica is availableSpeculative retry asks the third one. The read succeeds, just a bit slower.
…it was asked, and there's no spare to try (reading at ALL, RF=2, or speculative_retry: NONE)The read waits the full 5 seconds (read_request_timeout), then fails with ReadTimeoutException.

This is also why ALL can't survive a dead node on reads, not just on writes. It already asks every replica, so there's no spare left for speculative retry to try.

Putting It Together: One QUORUM Read, Start to Finish

Here are all the pieces above, in the order they happen. The example: RF=3, replicas A, B and C, reading at QUORUM (needs 2 answers).

  1. The client sends the read to one node. That node is the coordinator for this request. Smart ("token-aware") drivers usually send it straight to a node that holds the data, which saves a network hop.
  2. The coordinator works out where the row lives. It hashes the partition key and looks it up on the ring: this row lives on A, B and C.
  3. It skips replicas it thinks are down. That's based on its own gossip view, not a cluster-wide vote. If fewer than 2 are left, it fails right away with UnavailableException and sends nothing.
  4. It picks just 2 replicas, not all 3. The dynamic snitch ranks them by recent speed. Say A is fastest, then B. C isn't asked.
  5. A sends the data, B sends a fingerprint. A returns the actual rows. B runs the same query and returns only a hash.
  6. Each replica reads from its own storage. Memtable, caches, bloom filters, SSTables: how a single node reads is covered in Part 5.
  7. If A or B is slow, it asks C. If one hasn't answered by the speculative_retry threshold, the coordinator sends the same request to C. This is the only time C hears about this read. If there still aren't 2 answers after 5 seconds (read_request_timeout), the read fails with ReadTimeoutException.
  8. It compares the two answers. If the fingerprint matches the data, it returns the data. This is almost always what happens.
  9. If they don't match, it fixes things first. It fetches the full data from both replicas, keeps the newest value for each cell (by timestamp), writes that value back to the stale replica (read repair, §5), and returns it to the client.

The key difference: a write goes to all 3 replicas and waits for enough of them to confirm. A read goes to only as many replicas as it needs, and reaches the third one only through speculative retry. That one difference explains most of how reads and writes behave when a node fails.

What the Formula Does NOT Protect You From

R + W > N guarantees one thing: once a write has succeeded, a later read will see it. It does not cover:

  1. Two writes at the same time. If two clients write the same row at nearly the same moment, the formula doesn't say which should win, and both can be told "success".
  2. Wrong clocks. Cassandra picks the "latest" write by its timestamp (last-write-wins). If one server's clock runs ahead, an older write can beat a newer one.
  3. Transactions. You can't safely read a value, decide something, and write it back. Nothing locks the row between your read and your write.

R + W > N means "a read will see any write that already finished". It isn't a transaction, and it doesn't settle races.

  • Guarantees: Once a write has succeeded at W, any read at R asks at least one replica that has it. A finished write never disappears from reads.
  • Does not guarantee: Anything about writes still in progress, which of two simultaneous writes wins, or whether the timestamps used to decide are correct.

Walkthrough: What Divergence Actually Looks Like

Case 1: One Replica Misses the Write

Setup: replicas A, B and C. RF=3, writes and reads both at QUORUM (2).

  1. The client sends a write. The coordinator sends it to A, B and C.
  2. C goes down before the write reaches it. A and B save it.
  3. The coordinator has 2 confirmations, which is enough for QUORUM. It tells the client "success".
  4. Later, a QUORUM read asks 2 of the 3 replicas.
Three replicas with RF 3 and QUORUM writes and reads. Replicas A and B hold the new value; replica C was down and still holds the old value. The write was acknowledged because two of three replied. A read that hits A and B sees only the new value. A read that hits A and C sees one new and one old value, and returns the new one only because its timestamp is higher.
Case 1 — C misses the write, and every QUORUM read still overlaps A or B
  • Read asks A and B: both have the new value. Correct.
  • Read asks A and C (C is back but hasn't caught up yet): one new value, one old. Cassandra returns the one with the newer timestamp, so the answer is correct. But it only works because the old value carries an older timestamp.

Case 2: Two Writes Race Each Other

In Case 1, C just missed one write. A more realistic problem: two clients write the same row at almost the same time, and each write reaches a different pair of replicas.

Two clients write the same row at nearly the same time, RF 3. Client 1 writes "online" at timestamp 100 to replicas A and B; two of three is quorum, so it is acked as success. Client 2 writes "offline" at timestamp 102 to replicas B and C; also quorum, also acked. End state: A holds "online" at 100, having seen only write 1; B holds "offline" at 102, having seen both and kept the higher timestamp; C holds "offline" at 102, having seen only write 2. Every QUORUM read hits B or C and returns "offline". Client 1’s acknowledged write is gone and Client 1 is never told.
Case 2 — both writes meet quorum, both are acked, one of them ceases to exist

Readers are fine. Every QUORUM read asks 2 replicas, so it always hits B or C, and both hold "offline", the newer value. Every read returns the same answer.

A still holds the old "online" while B and C hold "offline". Fixing that kind of mismatch is the job of repair. The next two sections cover two cheaper mechanisms that fix some of it first.

  • Guarantees: In both cases, every QUORUM read returns the value with the newest timestamp. Readers never see the replicas disagree.
  • Does not guarantee: That a successful write will survive, or that anyone is told when it doesn't. There is no conflict warning of any kind.

Hinted Handoff

When replica C is down, the coordinator saves a hint: a small note that says "here's a write C missed, give it to C when it's back." When C returns, the node holding the hint sends C those missed writes, and C catches up without a full repair.

How the Coordinator Knows C Is Down

Nobody announces it. Nodes constantly pass heartbeats around through gossip (Part 2 §5). Each node watches those heartbeats on its own and keeps a suspicion score for every other node (the Phi Accrual failure detector). When C's score passes phi_convict_threshold (default 8, about 10 seconds of silence on a healthy network), that node marks C as DOWN, in its own view only. There's no cluster-wide vote, so two coordinators can briefly disagree about whether C is up.

What the coordinator believes when the write arrives decides what it does:

The coordinator thinks C is…What happens
DOWNIt doesn't send the write to C. It saves a hint right away.
UP, but C is actually dead (not noticed yet)It sends the write, C never confirms, and when write_request_timeout runs out it saves a hint anyway.
(Too few replicas are up for the consistency level)It fails right away with UnavailableException. Nothing is written, and no hint is saved.

So slow failure detection doesn't leave a gap on its own: even if gossip still thinks C is alive, the timeout catches the missed write and a hint is saved. Delivery works the same way in reverse. Once C's heartbeats come back and gossip marks it UP, every node holding hints for C starts sending them.

When Hints Don't Save You

Hints are best-effort. There are real ways C can end up missing data with nothing queued to fix it:

  • The coordinator dies. Hints are stored only on the coordinator's own disk, with no copies. If it crashes before saving or delivering them, they're gone.
  • C is down too long. Once C has been down longer than max_hint_window (3 hours by default), coordinators stop saving hints for it. Every write after that is simply missed.
  • Hints get thrown away. Hints are turned off (hinted_handoff_enabled: false), hint storage is full, or the hints are older than the table's gc_grace_seconds. (That age limit exists so an old hint can never bring a deleted row back.)
  • C is still catching up. C is marked UP and answering reads while it's still working through its backlog of hints, so for a while it's online but behind.

That's why hints are only the first of three safety nets:

  • Quorum (§2): the write still reached enough other replicas, so a QUORUM read will hit at least one up-to-date copy.
  • Read repair (§5): fixes stale copies of rows that get read.
  • Scheduled nodetool repair: the only thing that guarantees C eventually has everything.
A write arrives with RF 3. Replicas A and B take it; replica C is down, so the coordinator stores a hint saying C missed this write. A time axis runs from the write to 3 hours, the default hint window, and beyond. If C returns inside the window, the hint is replayed and C is caught up with no repair needed. At the 3-hour mark the hints are discarded; if C returns after that, it rejoins looking healthy but is silently missing the write, and only nodetool repair can reconcile it.
Inside the 3-hour window a hint heals C; past it, C is silently missing the write
Default hint window3 hours (max_hint_window_in_ms)
After the windowno more hints are saved, and nothing shows the gap
The only fix after thatrun nodetool repair
  • Guarantees: A replica that comes back within the hint window catches up on the writes it missed, without anyone doing anything.
  • Does not guarantee: Anything after the window, or for hints held by a coordinator that itself failed. Hints are a convenience, not a way to keep data safe.

Read Repair

During a QUORUM read, the fingerprints sometimes don't match. Maybe a replica missed a write, or came back before its hints finished arriving. When that happens, the coordinator fetches the full data from the replicas it asked and keeps the value with the newest timestamp (last-write-wins). It returns that value to the client and also writes it back to any replica that had an old copy. That's read repair.

Foreground read repair

Happens when the read already asks more than one replica (QUORUM, ALL, and so on). The coordinator already has both answers in hand, so it compares them on the spot.

Background read repair

For a small, random share of reads, even LOCAL_ONE ones, the coordinator also checked the other replicas behind the scenes. Controlled by read_repair_chance. (Removed in 4.0, see below.)

Why the background version existed: a LOCAL_ONE read asks only one replica, so there's nothing to compare against and foreground repair can never happen. The background version meant even those cheap reads got checked now and then, instead of letting replicas drift apart forever.

A client issues a LOCAL_ONE read. The coordinator queries one replica and returns the answer immediately, so the client is never blocked. Off the critical path, a random draw against read_repair_chance decides what happens next: about 90 percent of the time nothing does; about 10 percent of the time the coordinator queries the other replicas in the background, and if they disagree it pushes the highest-timestamp value to whichever replica was stale. This mechanism was removed in Cassandra 4.0.
Background read repair on a LOCAL_ONE read — entirely off the client’s critical path

Across many requests, this randomly checked a small share of cheap reads. The cost of checking was spread out over time instead of being added to every read.

On 4.0+, a LOCAL_ONE Read Fixes Nothing

That version note matters a lot, because LOCAL_ONE is the driver default.

Before 4.0, a LOCAL_ONE read still helped a little: thanks to read_repair_chance, some of those reads checked the other replicas in the background. On 4.0 and later that's gone. A LOCAL_ONE read asks one replica, returns whatever it says, and fixes nothing.

On 4.0+, reading at LOCAL_ONE doesn't just give up the fresh-read guarantee for that query. The read also does nothing to bring replicas back in sync.

Put that next to the other two mechanisms in this part:

MechanismWhat it fixesDoes it help if you only read at LOCAL_ONE?
Hinted handoff (§4)Writes missed during a short outageYes, but only within the 3-hour window, and only if the coordinator holding the hint survives
Read repair (§5)Stale copies of rows that get readNo. On 4.0+ it never runs for single-replica reads
nodetool repairEverything, including data nobody readsYes, but only when someone runs it

So if a 4.0+ cluster only ever reads at LOCAL_ONE, there are just two ways replicas get back in sync: hints (which expire after 3 hours and vanish if their coordinator dies) and scheduled repair. If repair isn't actually scheduled and finishing, replicas drift apart and every read is a coin flip over which copy you get.

  • Guarantees: Any row read from more than one replica gets its stale copies fixed as a side effect.
  • Does not guarantee: Full coverage. What gets fixed depends entirely on what gets read, so the least-read data, usually the oldest and most out of sync, gets fixed last or never.

What "Eventual Consistency" Actually Means Here

What people often assumeWhat it actually means
"My write will be visible everywhere within a few milliseconds."Cassandra makes no promise about how long it takes. Usually it's under a second, but nothing guarantees that.

Cases where "eventually" can mean never:

  1. A node that was down for 4 hours, past the hint window, won't catch up until someone runs repair (§4).
  2. A row that's never read never gets read-repaired (§5).
  3. When two writes race, the newest timestamp wins. If a clock is wrong, an older write can permanently replace a newer one (§3).

Eventual consistency means "replicas will end up agreeing, given enough time and no new writes." It says nothing about how long that takes, or whether racing writes end up correct.

The takeaway from this part: there are two kinds of promises. A liveness promise says something good will eventually happen. A safety promise says something bad will never happen. Cassandra's default model gives you the first, not the second. That's fine, as long as your app isn't secretly counting on the second.

  • Guarantees: Replicas eventually agree on data that gets read or repaired, as long as writes stop and repair actually runs.
  • Does not guarantee: A deadline, correct results when writes race, or that anyone is ever told about a conflict.