Skip to content

Quorums and Leaderless Replication

Advanced 41 min read Part 6 of 18

Dynamo-style replication: N, R, W and R+W>N, tunable consistency, sloppy quorums and hinted handoff, read repair, Merkle-tree anti-entropy and vector clocks.

Summary#

In leaderless replication there is no primary: a client (or a coordinator node) sends every write to all N replicas of a key and waits for W acknowledgements, and every read asks replicas and waits for R responses. If R + W > N, every read set overlaps every write set, so a read sees at least one copy of the latest acknowledged write. Choosing R and W per request gives tunable consistency. When replicas are down, sloppy quorums with hinted handoff keep writes flowing. Stale copies are fixed by read repair and background anti-entropy using Merkle trees. Concurrent writes are detected with version vectors (vector clocks). This is the Dynamo-style design behind Cassandra, ScyllaDB, Riak and Voldemort.

Why It Exists#

Leader-based replication has a weak moment: when the leader fails, writes stop until failover completes, which takes seconds to minutes and risks split-brain. Amazon's shopping cart could not afford that: "add to cart" had to work even while servers and network links failed. The Dynamo paper (2007) described a design with no leader at all: any replica can accept writes, and the system tolerates failures by asking for a majority-like overlap instead of one authority. The price is weaker consistency and conflicts the application may need to merge. This page builds on Consistent Hashing, which decides which N nodes hold each key.

How It Works#

N, R, W and R + W > N#

  • N: number of replicas for each key (commonly 3).
  • W: replicas that must acknowledge a write before it is reported successful.
  • R: replicas that must respond to a read before the result is returned.

The write is sent to all N replicas; W is only how many we wait for. Similarly, reads may ask all N but return after R replies, choosing the newest version among them.

If R + W > N, any set of R replicas shares at least one node with any set of W replicas, so a read includes at least one replica with the latest successful write. The common choice is N=3, R=2, W=2 (quorum reads and writes, where quorum = floor(N/2) + 1).

NRWR+W>N?Tolerates (reads / writes)Behaviour
322Yes (4 > 3)1 node down for bothBalanced default; reads see latest write
313Yes (4 > 3)Reads: 2 down; writes: none downFast reads; any failed node blocks writes
331Yes (4 > 3)Reads: none down; writes: 2 downFast, available writes; reads fragile and slow
311No (2 ≤ 3)2 down for bothFastest, most available; reads may be stale
533Yes (6 > 5)2 down for bothMore fault tolerance, more copies

Compare the two rows the trade-off usually turns on. With R=2, W=2, one slow or dead node never blocks anything. With R=1, W=3, reads are a single fast round trip, but one dead replica makes writes fail, so it only suits read-heavy data where write availability matters little.

Latency follows the slowest of the replicas you wait for: waiting for 2 of 3 hides one slow node, which is a big win for tail latency (p99).

Quorum arithmetic in depth#

Why overlap is guaranteed. The rule R + W > N is a counting argument. A write was acknowledged by some set of W replicas, and a read asks some set of R replicas, both drawn from the same N. If the two sets shared no replica, together they would contain R + W distinct replicas. But only N exist, and R + W is larger than N, so they must share at least one. With N = 3 and quorum = floor(3/2) + 1 = 2, any two replicas you write to and any two you read from have at least one in common, and that one has the write. The guarantee depends on the read choosing the newest version among the R replies. That needs a version number or timestamp on every value, which is why every leaderless store tags values with one.

Why odd N. With N = 4, a majority is 3, and the system still tolerates only one failure for quorum operations, the same as N = 3, while paying for a fourth copy. N = 5 with quorum 3 tolerates two failures. So N is almost always odd: 3 for ordinary data and 5 for data that must survive two simultaneous failures, such as a zone outage plus one unrelated node.

Availability, computed. Suppose each replica is independently up 99% of the time. A W = 2 of N = 3 write succeeds when at least two replicas are up: 3 × 0.99² × 0.01 + 0.99³ ≈ 0.9997. That is about 2.6 hours of quorum unavailability a year, versus 3.65 days for a single replica. A W = 3 write needs all three: 0.99³ ≈ 0.970, which is worse than a single node, at about 11 days a year. This is why ALL is rarely used for anything that must stay up. Real failures are correlated (a rack switch, a bad deploy, a zone), so placement across racks and zones matters as much as the arithmetic.

Latency, computed. Waiting for 2 of 3 means waiting for the second-fastest reply. If each replica independently exceeds 20 ms with probability 1% (its p99), the 2-of-3 wait exceeds 20 ms only if at least two replicas are slow: 3 × 0.01² × 0.99 + 0.01³ ≈ 0.0003. The quorum's p99.97 is therefore about the single replica's p99, so quorums improve tail latency compared with asking one specific replica. Asking only one replica (R = 1) gets that replica's full tail. This is why Cassandra also supports speculative retry: if a replica has not answered by about its observed p99, the coordinator sends the same read to another replica and uses whichever answers first.

Partial writes are not rolled back. The coordinator sends the write to all N replicas but waits for only W acknowledgements. If fewer than W acknowledge in time, the client gets an error, but the replicas that did apply the write keep it. There is no rollback. Later reads may or may not see the value, and anti-entropy will eventually spread it to all replicas. A failed quorum write therefore means "unknown outcome", not "did not happen". Clients must treat writes as idempotent and retry them, usually with the same timestamp or version, so a retry does not create a second, different write.

Who coordinates. A request needs a coordinator that fans out to replicas and counts replies. In Cassandra any node can coordinate. Token-aware drivers send each request to a node that is itself a replica, which saves a hop. Dynamo allowed either a client library that knew the ring, or a load balancer that forwarded to a random node. Coordinator choice affects latency (one extra hop is about 0.2-1 ms within a zone) and failure behaviour, because the coordinator holds hints for unreachable replicas, as described below.

Tunable consistency#

Because R and W are per request, the same database can serve strict and relaxed needs. Cassandra exposes consistency levels:

  • ONE: one replica (fast, may be stale).
  • QUORUM: majority of all replicas across data centres.
  • LOCAL_QUORUM: majority within the local data centre (avoids cross-region latency; the common choice for multi-DC clusters).
  • EACH_QUORUM: majority in every data centre (writes only).
  • ALL: every replica (strongest, least available).
-- cqlsh examples
CONSISTENCY LOCAL_QUORUM;
INSERT INTO carts (user_id, item_id, qty) VALUES (42, 'sku-9', 1);
CONSISTENCY ONE;
SELECT * FROM product_views WHERE product_id = 'sku-9';   -- staleness ok

Pick per use: LOCAL_QUORUM for both reads and writes on user data, ONE for analytics counters or logs. Note that even R + W > N does not give linearizability in every case: concurrent writes, failed partial writes and sloppy quorums can still produce anomalies. Cassandra offers lightweight transactions (Paxos-based compare-and-set) when you truly need it. See Consistency Models.

Tunable consistency in depth#

The full menu. Cassandra's consistency levels go beyond the common five. TWO and THREE wait for exactly that many replicas. LOCAL_ONE waits for one replica in the local data centre, which is the usual choice for tolerant reads in multi-region clusters, because plain ONE might be answered from a remote region. ANY (writes only) succeeds even if no replica is reachable, as long as the coordinator stored a hint. It is the most available and least safe level, because a coordinator failure can lose the write. SERIAL and LOCAL_SERIAL are used for lightweight transactions, described below.

Multi-data-centre arithmetic. With two data centres and a replication factor of 3 in each, there are 6 replicas. QUORUM then means 4 of 6, which always involves the remote data centre and so costs a cross-region round trip of 60-150 ms. LOCAL_QUORUM means 2 of the 3 local replicas, about 1-5 ms. EACH_QUORUM means 2 in every data centre. Writing and reading at LOCAL_QUORUM gives the overlap guarantee within a data centre, but a reader in the other region may not see the write until asynchronous cross-region replication delivers it, typically within tens to hundreds of milliseconds. That is exactly the right trade for most user data, because a user's own requests are routed to one region, so they read their own writes. Cross-region readers see eventual consistency.

Combining levels on purpose. Consistency is a property of the pair of levels a write and a later read use:

Write levelRead levelOverlap (RF 3)?Typical use
QUORUM / LOCAL_QUORUMQUORUM / LOCAL_QUORUMYes (2 + 2 > 3)User data, read-your-writes
ALLONEYes (3 + 1 > 3)Rarely written config, fast reads
ONEALLYes (1 + 3 > 3)Write-heavy data read rarely
ONEONENoMetrics, logs, view counts

Lightweight transactions. When an operation must be atomic compare-and-set, such as "create this username only if it does not exist" or "reserve this seat only if it is still free", Cassandra offers INSERT ... IF NOT EXISTS and UPDATE ... IF col = value. These run a Paxos protocol among the key's replicas, taking about four round trips: prepare and promise, read the current value, propose and accept, then commit. So a lightweight transaction costs several times a normal quorum write, and contention on one key makes it much slower. Use them for the few operations that need linearizability, not as a default. The read side uses SERIAL to see the result of in-progress Paxos rounds.

Other systems' knobs. Riak exposes r and w per request, plus pr and pw (how many of the replies must come from primary replicas rather than fallbacks in a sloppy quorum) and dw (how many replicas must confirm a durable write to disk rather than just receipt). Those extra knobs make the sloppy-quorum trade-off explicit per request. DynamoDB offers a per-read choice between eventually consistent reads and strongly consistent reads. A strongly consistent read is served by the partition's leader and costs twice the read capacity: one read capacity unit buys one strongly consistent read of up to 4 KB, or two eventually consistent ones. ScyllaDB implements Cassandra's levels unchanged.

Picking levels in practice. Start from what an anomaly would cost. A stale product view count costs nothing, so use ONE. A user not seeing their own profile edit is a visible bug, so use LOCAL_QUORUM for both writes and reads. A duplicate username is a correctness bug, so use a lightweight transaction. Most production Cassandra fleets settle on LOCAL_QUORUM for almost everything, LOCAL_ONE for analytics-style reads, and lightweight transactions for a handful of uniqueness checks.

Sloppy quorums and hinted handoff#

What if some of a key's N "home" replicas are unreachable? A strict quorum fails the write. A sloppy quorum accepts the write on other healthy nodes that are not normally responsible for that key, so the write still gets W acknowledgements. Each such node stores a hint: "this write belongs to node C". When C comes back, the node hands off the write and deletes the hint. This is hinted handoff.

  • Gain: writes stay available during node failures and network partitions.
  • Cost: R + W > N no longer guarantees overlap, because the W nodes may not be among the N home nodes that a read asks. A sloppy quorum is an availability guarantee, not a consistency one.

Riak and Dynamo used sloppy quorums. Cassandra uses hinted handoff to catch up replicas faster, but its quorum counts only real replicas (so it is a strict quorum); hints are stored for a limited window (3 hours by default), after which a repair is needed.

Sloppy quorums and hinted handoff in depth#

A concrete failure. Key cart:42 has home replicas A, B and C, and the ring's next nodes clockwise are D and E. Replica C is unreachable because its rack switch has failed. With a strict quorum (W = 2), writes still succeed via A and B, and C simply misses them. With a sloppy quorum, the coordinator walks further along the preference list. It takes the first N healthy nodes, A, B and D, and sends D the write tagged with a hint that it really belongs to C. D stores it in a separate local hint store, not in its normal data. When gossip reports C alive again, D replays the hinted writes to C and deletes them.

Why sloppy quorums break overlap. Suppose A and B are partitioned away from a group of clients, and those clients' writes are accepted by D and E as fallbacks. W = 2 is satisfied, but by two nodes that are not home replicas. A later read that reaches A and B (R = 2) sees none of these writes, even though R + W > N. Overlap only holds when both quorums are drawn from the same N nodes. Sloppy quorums trade that guarantee for write availability: the shopping cart keeps accepting "add item" as long as any W nodes are reachable. That was Amazon's stated requirement in the Dynamo paper, and it explains why the cart then needed conflict merging.

Cassandra's version. Cassandra keeps quorums strict. Only real replicas count toward the consistency level, except at ANY. It still uses hints to speed up recovery. When a replica is down, the coordinator stores a hint locally (in flat files since Cassandra 3.0). It keeps hints for at most max_hint_window, 3 hours by default, and replays them, throttled, when the replica returns. If a node stays down longer than the window, the coordinator stops collecting hints for it. That node must then be brought up to date by repair, and long-dead nodes are usually rebuilt or replaced instead.

Limits of hints. Hints are an optimisation, not a guarantee:

  • If the node holding hints dies before delivering them, the hints are lost. The writes still exist on the replicas that acknowledged them, but the recovering replica must get them through repair.
  • A flood of hints for a node that was down for hours can overwhelm it on return, which is why delivery is throttled.
  • Hints accumulate on coordinators during long outages and use disk there, which is one reason for the time window.

Hinted handoff, read repair and anti-entropy are therefore layers. Hints handle outages of seconds to hours cheaply, read repair handles frequently read keys, and full anti-entropy guarantees convergence for everything else.

Read repair#

When a read collects responses and finds that some replicas returned an older version, the coordinator writes the newest version back to the stale replicas. This is read repair, shown at the end of the sequence above. It fixes frequently read keys quickly, but keys that are rarely read may stay stale for a long time, so it is not enough on its own.

Read repair in depth#

Digest reads. Sending every replica the full value on each read would multiply network traffic by R. Cassandra instead asks one replica, usually the fastest by its dynamic "snitch" latency scores, for the full data, and asks the others only for a digest, a hash of their answer. If all digests match the hash of the full data, the read returns immediately. If they differ, the coordinator requests full data from the mismatching replicas, reconciles the versions (the newest timestamp per cell wins), returns the result, and writes the reconciled value back to the replicas that were behind.

Blocking versus background repair. If the coordinator waits for the repair writes to be acknowledged before answering, the repair is blocking. This gives an important guarantee: once a quorum read has returned a value, later quorum reads cannot return an older one, because at least a quorum now holds the newer value. That is monotonic reads across clients for quorum operations. Without blocking repair, two consecutive quorum reads could disagree while a partially applied write is still spreading. Cassandra 4.0 made this a per-table option, read_repair = 'BLOCKING' (the default) or 'NONE'. It also removed the older probabilistic read_repair_chance settings, which triggered background repair on a random fraction of reads and were a common source of confusion and wasted work.

What read repair cannot do. It only fixes keys that are read, and only among the replicas that took part in that read. A key read at ONE is never compared with anything. A key nobody reads for a month stays divergent for a month. Read repair also adds write load on the read path, which can surprise capacity planning after an outage, when many reads find stale replicas at once. And it cannot resolve deletes that a replica never saw if the tombstone has already been purged elsewhere. That case needs repair to run within the tombstone grace period, as described next.

Choosing. Keep blocking read repair for tables read at QUORUM or LOCAL_QUORUM, where monotonic reads matter. Consider NONE for tables written with timestamps the application controls, or read only at ONE, where repair adds cost without any guarantee. Either way, schedule full anti-entropy regularly.

Anti-entropy with Merkle trees#

Anti-entropy is a background process that compares replicas and copies missing or newer data between them. Comparing every key over the network would be far too expensive, so replicas build Merkle trees (hash trees):

  • Each leaf is a hash of a small key range's data.
  • Each parent is a hash of its children's hashes; the root summarises the whole range.
  • Two replicas compare roots. If equal, the data is identical. If not, they compare children and descend only into subtrees whose hashes differ.

So finding a few differing keys among millions costs a few hash exchanges and transfers only the differing ranges. Cassandra's nodetool repair builds Merkle trees for token ranges; operators run it regularly (within the tombstone grace period, 10 days by default) so that deletes are not resurrected.

Together the three mechanisms form layers: hinted handoff for short outages, read repair for hot keys, Merkle-tree anti-entropy for everything else.

Merkle trees and repair in depth#

The data structure. A Merkle tree, named after Ralph Merkle, who described hash trees in his work on digital signatures in the late 1970s (published at CRYPTO 1987), is a binary tree of hashes. Leaves hash the data in small pieces, here key ranges, and each inner node hashes the concatenation of its children. The root therefore depends on every byte below it, and two replicas with the same root hold the same data with overwhelming probability. Comparing trees top-down finds differences in O(d log L) hash comparisons, where d is the number of differing leaves and L the number of leaves, instead of comparing all the keys. Git, Bitcoin, ZFS, IPFS and certificate transparency logs use the same structure for the same reason.

Sizing the tree, and overstreaming. A tree's resolution is its number of leaves. Cassandra builds one tree per token range being repaired, with a depth of about 15, or 32,768 leaves. Picture a node holding 1 TB in one repaired range. Each leaf then covers about 30 MB of data. If a single key differs, the whole 30 MB leaf range is streamed, because the tree cannot say which key in the leaf changed. This overstreaming is the main cost of Merkle repair on dense nodes. The standard remedies are subrange repair, which repairs many small token slices so each tree covers less data and each leaf fewer bytes, and incremental repair, which marks data that has already been repaired and only builds trees over data written since. Incremental repair was unreliable in some Cassandra 3.x releases and was substantially reworked in 4.0. Operators typically use a scheduler such as Cassandra Reaper to run subrange repairs continuously across the cluster without overloading it.

Why repair is mandatory: deletes. In a leaderless store, a delete is a write of a tombstone, a marker saying "this value was deleted at time T". Tombstones are kept for gc_grace_seconds (864,000 seconds, or 10 days, by default) and then purged during compaction. Now picture replica C down during the delete, so it still holds the old value. If C comes back after A and B have purged their tombstones, repair sees a live value on C and nothing on A and B, and "repairs" the value back onto A and B. The deleted data rises from the dead. This is called zombie data or resurrection. The only defence is to make sure every replica has seen every tombstone before the grace period ends, which means completing a full repair of every range at least once per gc_grace_seconds. It is the single most important operational rule for Cassandra.

Dynamo and Riak. The Dynamo paper describes a Merkle tree per key range held by a node. These are cheap to compare between replicas, but they must be recalculated when ring membership changes, because ranges change. Riak's active anti-entropy kept persistent, incrementally updated hash trees on disk and exchanged them continuously in the background, so divergence was found within minutes rather than at the next scheduled repair.

Beyond Merkle trees. Set reconciliation is an active research area. Invertible Bloom lookup tables (Eppstein, Goodrich, Uyeda and Varghese, "What's the Difference? Efficient Set Reconciliation without Prior Context", SIGCOMM 2011) let two parties find their differing items with communication proportional to the size of the difference, without building a tree over the whole set. Some newer systems use this for gossip-based synchronisation. For databases, Merkle trees remain the standard because they fit naturally with range-partitioned data and incremental rebuilds.

Vector clocks for conflicts#

Without a leader, two clients can write the same key at the same time through different replicas. The database must tell whether one write happened after another (then the newer one simply replaces it) or whether they are concurrent (a real conflict).

A version vector (often called a vector clock) is a list of counters, one per replica that has coordinated writes to the key, such as {A:2, B:1}. Rules:

  • Version X descends from Y if every counter in X is greater than or equal to the one in Y: then X replaces Y.
  • If neither descends from the other ({A:2, B:1} vs {A:1, B:2}), they are concurrent: both are kept as siblings.

Example with a shopping cart:

  1. Cart is [milk] with version {A:1}.
  2. Client 1 adds eggs through replica A: [milk, eggs], version {A:2}.
  3. Client 2, still holding {A:1}, adds bread through replica B: [milk, bread], version {A:1, B:1}.
  4. Neither {A:2} nor {A:1, B:1} descends from the other, so the next read returns both siblings. The application merges them (union: [milk, eggs, bread]) and writes back with version {A:2, B:1}, which descends from both.

The Dynamo paper describes exactly this, and notes that union merges can resurrect deleted items. The alternative, last write wins (LWW) by timestamp, is simpler but silently discards one of the concurrent writes; Cassandra uses LWW per column. CRDTs are data types that merge automatically (Riak offered them). See Time and Ordering.

Versioning and conflicts in depth#

From Lamport to vector clocks. Leslie Lamport's "Time, Clocks, and the Ordering of Events in a Distributed System" (CACM, 1978) defined happened-before: event a happened before b if they occur in the same process in that order, or a is a send and b the matching receive, or the relation follows by transitivity. Events not related by happened-before are concurrent. Lamport clocks give an order consistent with happened-before, but they cannot detect concurrency. Two concurrent events still get different numbers that look ordered. Colin Fidge and Friedemann Mattern independently introduced vector clocks in 1988. These carry one counter per process and capture happened-before exactly, so two clocks either compare in order or are incomparable, meaning concurrent.

Version vectors versus vector clocks. The terms are often mixed up. A vector clock tracks causality between events in processes. A version vector tracks causality between versions of one data item across the replicas that update it. Databases use version vectors: each key has its own small vector, with one entry per replica (or per coordinator) that has written to it. The comparison rules are the same: equal-or-greater in every entry means "descends from".

Who gets an entry. If the vector has one entry per client, it grows with the number of clients, which in a busy web store means millions of entries. If it has one entry per server, two clients writing through the same server can create a version that wrongly appears to descend from the other. One client's update would then silently overwrite another's, a false "happened-before". The Dynamo paper accepted per-server entries and also truncated the vector when it exceeded a threshold (about ten entries), dropping the oldest, which could cause false conflicts in rare cases. Dotted version vectors (Preguiça, Baquero and colleagues, around 2010-2012) attach an extra "dot", identifying the single event that produced each sibling, to a per-server vector. Riak adopted them to track causality exactly with server-sized vectors and to stop "sibling explosion", where repeated concurrent writes multiplied the number of siblings.

Last write wins, and what it loses. Cassandra avoids siblings entirely. Every cell carries a microsecond timestamp, usually set by the coordinator or the client, and the highest timestamp wins on every read and repair. It is simple and needs no merge code, but it silently drops concurrent updates. If two users edit the same column within the same few milliseconds, one edit disappears without an error. It also depends on clocks: a client whose clock is 5 seconds fast wins every conflict for 5 seconds, even against later writes. Mitigations include NTP or chrony on every node with alerting on drift, generating timestamps on the server side, designing tables so concurrent writers touch different cells (one row per item instead of a list column, for example), and using lightweight transactions where order truly matters.

Merging siblings. When a store returns siblings, as Riak with allow_mult and Dynamo did, the application must merge them and write back the result with a vector that descends from all siblings. The merge function must be deterministic and should be commutative, associative and idempotent, so that merging in any order, or more than once, gives the same answer. The shopping-cart union merge has a known flaw: an item deleted in one sibling and still present in another comes back after the union. The fix is to record removals explicitly. An observed-remove set (OR-Set) tags each add with a unique ID and has removals delete specific tags, so a concurrent add and remove of the same item resolve predictably.

CRDTs. Conflict-free replicated data types (Shapiro, Preguiça, Baquero and Zawirski, 2011) package such merge rules into reusable types. A G-counter keeps one count per replica and sums them. A PN-counter is two G-counters, one for increments and one for decrements. An OR-Set handles concurrent add and remove. A LWW-register holds a single value with timestamp-based resolution. Maps compose these. Riak exposed counters, sets, maps and flags as built-in data types, and Redis Enterprise's active-active replication uses CRDTs under the hood. See Collaborative Editing and CRDTs.

Dynamo-style design#

Putting it together, a Dynamo-style store combines:

ProblemTechnique
PartitioningConsistent hashing with virtual nodes
ReplicationN replicas on the next distinct nodes on the ring (preference list)
ConsistencyTunable R and W quorums
Temporary failuresSloppy quorum and hinted handoff
Permanent divergenceRead repair and Merkle-tree anti-entropy
Concurrent writesVersion vectors with application merge, or LWW
Membership and failure detectionGossip protocol, no central master

Dynamo itself was an internal Amazon system; DynamoDB shares its name and ideas such as partitioning but is a different, leader-based design per partition. The open-source descendants of the Dynamo paper are Cassandra (which combined it with Bigtable's data model), Riak and Voldemort. See Failure Detection and Gossip.

Dynamo-style systems in depth#

A write and a read, end to end. Follow one request through a Cassandra-like cluster with RF = 3 in one region at LOCAL_QUORUM:

  1. The driver hashes the partition key, finds the three replicas from its cached ring, and sends the write to one of them, which acts as coordinator. That saves a hop.
  2. The coordinator forwards the write, with a timestamp, to the other two replicas. Each appends it to its commit log (sequential disk write) and to an in-memory memtable. It acknowledges in about 0.5-2 ms.
  3. After two acknowledgements, the coordinator replies to the client. A third, slower replica applies the write a few milliseconds later. If that replica is down, the coordinator stores a hint for it.
  4. A read for the same key goes to a replica coordinator. It requests full data from the fastest replica and a digest from one more. Digests match, so it answers in about 1-3 ms. If they had not matched, it would reconcile by timestamp, return the newest value, and block on repairing the stale replica.
  5. In the background, scheduled subrange repair compares Merkle trees for every range within the 10-day tombstone window, so even never-read keys converge.

How the main systems differ:

SystemReplicationConflict handlingRepairNotes
Dynamo (Amazon, 2007 paper)Leaderless, sloppy quorum, N=3 R=2 W=2 typicalVersion vectors, siblings merged by the applicationMerkle trees per range, hinted handoffInternal Amazon system, never sold
CassandraLeaderless, strict quorums with hints, per-DC replicationLWW per cell by timestamp; LWT via PaxosMerkle repair (full, incremental, subrange), read repairBigtable-style data model on a Dynamo-style ring
ScyllaDBSame as Cassandra (compatible protocol)Same as CassandraRow-level repair that streams only differing rowsC++ shard-per-core design, tablets for placement
Riak KVLeaderless, sloppy quorum, pr/pw/dw knobsSiblings with dotted version vectors, CRDT typesActive anti-entropy, read repairSmaller community today
Voldemort (LinkedIn)Leaderless, quorumsVector clocksRead repair, hinted handoffLargely retired
DynamoDBLeader per partition, Multi-Paxos group across 3 AZsLeader orders writes; LWW across Global Tables regionsInternalShares the name, not the leaderless design

Quorums beyond leaderless stores. The intersection idea is everywhere, not only in Dynamo-style systems. Raft and Paxos commit a log entry once a majority of the group stores it, and elect a leader only with a majority's votes. Because any two majorities intersect, a new leader always has every committed entry. Amazon Aurora (Verbitski et al., SIGMOD 2017) keeps six copies of each storage segment, two in each of three availability zones. It uses a write quorum of 4 of 6 and a read quorum of 3 of 6. Since 4 + 3 > 6, reads overlap writes. Since 4 + 4 > 6, two conflicting writes cannot both succeed. And the volume survives losing a whole zone plus one more node for reads (3 copies remain) while keeping writes available after losing a whole zone (4 remain). Flexible Paxos (Howard, Malkhi and Spiegelman, 2016) showed that Paxos only needs the leader-election quorum to intersect the replication quorum, not every quorum to be a majority. A 10-node group could commit with 3 acknowledgements if elections require 8. That trades slower, rarer elections for faster commits.

Gifford's weighted voting. The quorum idea itself is older than the web. David Gifford's "Weighted Voting for Replicated Data" (SOSP 1979) gave each replica a number of votes and required read quorums r and write quorums w with r + w greater than the total votes, and 2w greater than the total. Fast, reliable replicas can carry more votes. Today's N, R and W are the special case where every replica has one vote.

A worked design: a multi-region cart store#

Requirements. A retailer needs a cart service that never refuses "add to cart", even during a zone failure or a network partition between regions. It runs in two regions, US-East and EU-West. Peak load is 60,000 cart writes per second and 150,000 cart reads per second worldwide. Each user is normally served by their nearest region, and p99 latency must stay under 20 ms.

Topology. Each region runs a Cassandra-compatible cluster across three availability zones, with replication {'us-east': 3, 'eu-west': 3}. Every cart therefore has six replicas, three per region, one per zone. Writes and reads use LOCAL_QUORUM, 2 of the 3 local replicas. Cross-region replication is asynchronous, carried by the coordinators, which forward each write to one replica in the remote region, which in turn writes to its local peers.

Data model and conflicts. A cart is a partition keyed by user_id, with one row per item, keyed by item_id, holding the quantity and the time it was added. Concurrent changes to different items touch different cells, so last-write-wins on each cell loses nothing. Only concurrent changes to the same item's quantity can collide, and then the later timestamp wins, which users accept. Removing an item writes a tombstone for that row. That is the per-row equivalent of an OR-Set remove, and it avoids the "deleted item comes back" anomaly of whole-cart union merges. Timestamps are assigned by the coordinator, and clocks run chrony with alerts above 50 ms of drift.

Failure walk-through.

  • One zone fails in US-East. Each US cart still has two local replicas, so LOCAL_QUORUM succeeds. Coordinators store hints for the lost zone's nodes. When the zone returns within three hours, hints replay. If it takes longer, a subrange repair restores it.
  • The transatlantic link fails. Each region keeps serving its own users at LOCAL_QUORUM, and cross-region writes queue as hints on the coordinators. A user who flies from New York to London during the outage might briefly see an older cart in Europe. That is accepted and documented.
  • A replica's disk dies. The node is replaced with a new machine taking over its tokens, and it streams data from the two surviving local replicas. Until then, each affected range runs on two copies, still enough for quorum.

Capacity. At 60,000 writes per second, each written to 6 replicas, the fleet absorbs 360,000 replica writes per second, or 180,000 per region. At about 10,000-15,000 replica writes per second per node for this row size, each region needs roughly 15-18 nodes, plus headroom, so 24 per region. Reads at LOCAL_QUORUM touch two replicas, one full read and one digest, so 150,000 reads become about 300,000 replica reads, mostly served from the memtable and cache because carts are small and hot.

Checkout is different. When the user checks out, the order service reads the cart at LOCAL_QUORUM and then reserves inventory in a separate, strongly consistent system. Carts tolerate eventual consistency. Stock levels and payments do not, and the design keeps them apart.

Operating a leaderless cluster in depth#

What to monitor. Leaderless systems fail quietly: requests keep succeeding while replicas drift apart. So watch the convergence machinery as closely as latency and errors:

  • Hints pending and hints replayed per node. A growing backlog means a replica is down or slow, and it predicts a storm of hint replay when it returns.
  • Dropped mutations. In Cassandra these are writes a replica received but discarded because they sat in its queue past the timeout. Each one is a replica that silently missed a write and will need repair.
  • Read repair rate: the fraction of reads that found disagreement. A sudden rise means replicas are diverging, often from overload or a recent outage.
  • Repair progress: when each token range was last fully repaired, compared with gc_grace_seconds. Alert well before any range reaches the limit.
  • Coordinator timeouts and unavailable errors by consistency level, which show whether quorums are being lost or merely slow.
  • Tombstones scanned per read. Cassandra warns above 1,000 tombstones in one read and aborts the query above 100,000 by default. Queue-like access patterns that delete and re-read the same partition hit this regularly.
  • Clock skew between nodes and clients when using last-write-wins.

Testing correctness. Kyle Kingsbury's Jepsen analyses have repeatedly shown how leaderless stores behave under partitions and clock skew. His early Cassandra and Riak tests demonstrated that last-write-wins with skewed clocks, or with concurrent writes, loses acknowledged writes. They also showed that settings which look safe on paper, such as quorum reads and writes, do not give linearizable behaviour for read-modify-write sequences. Running a small Jepsen-style test against your own configuration, with concurrent writers, partitions injected with iptables and a checker comparing acknowledged writes with final state, catches misconfigurations before production.

Capacity and compaction. Every replica write turns into commit log and memtable writes, then SSTable flushes and compaction. Under size-tiered compaction, a node may temporarily need as much free disk as its largest set of SSTables being merged, so operators keep disks under about 50% full. Leveled compaction needs less headroom but more write I/O. Under-provisioned disks turn a routine compaction or a repair stream into an outage, which then produces more hints and more repair.

Rolling restarts and upgrades. Because every range has N replicas and quorum needs only a majority, nodes can be restarted one at a time with no downtime, as long as only one replica of any range is down at once. With rack- or zone-aware placement, operators restart an entire zone at a time, knowing every range keeps two copies elsewhere. Draining a node first (nodetool drain) flushes memtables and stops accepting writes, so its commit log replay on start is short.

Leaderless versus leader-based, compared#

The choice between leaderless quorums and a leader per partition is mostly about where you pay for failures.

Failover. A leader-based group (PostgreSQL with Patroni, MongoDB replica sets, Raft groups in CockroachDB or etcd) has a short window after a leader dies in which writes for that partition stop. Detection and election usually take a few seconds, and sometimes tens of seconds with conservative timeouts. A leaderless group has no such window. As long as W replicas are reachable, writes continue, and a dead replica is simply skipped. For systems where every second of write unavailability costs money, such as carts, telemetry ingestion and messaging, that difference is the reason to go leaderless.

Ordering. A leader gives every write to a partition a single order, so read-modify-write operations, uniqueness checks and conditional updates are natural and cheap. Without a leader, concurrent writes have no inherent order. You either accept last-write-wins, keep siblings and merge them, or run a consensus round (a lightweight transaction) for the operations that need order. In effect, you pay for ordering only on the operations that use it, rather than on every write.

Latency. A leader must be reached by every write, which can mean a cross-zone or cross-region hop for clients far from it. Followers must also confirm before commit if replication is synchronous. A leaderless write goes to the nearest replicas and waits for the fastest W, which hides one slow node. Leader-based reads from the leader are consistent but concentrate load. Reads from followers are cheap but may be stale, which mirrors the choice between ONE and QUORUM.

Operational burden. Leader-based systems concentrate complexity in failover: fencing, split-brain prevention and replica promotion. Leaderless systems spread it over time: repair scheduling, hint management, tombstone hygiene, clock discipline and conflict design. Teams that already run Cassandra well find its failure handling relaxing. Teams new to it most often get hurt by skipped repairs and by last-write-wins surprises.

A rule of thumb. Choose leaderless when write availability during failures is the top requirement, when data is naturally keyed with few cross-key invariants, and when concurrent updates to the same value are rare or mergeable. Choose leader-based or consensus-based replication when you need transactions, constraints or strictly ordered updates. Many large systems use both: a leaderless store for high-volume, merge-friendly data, and a consensus-backed store for the small set of facts that must never conflict.

When to Use It#

  • Write-heavy workloads that must keep accepting writes during node failures: carts, sessions, messaging, IoT, activity logs.
  • Multi-data-centre deployments where each region should read and write locally (LOCAL_QUORUM).
  • Data with clear merge rules or where last-write-wins is acceptable.
  • Clusters large enough that some node is always failing or being replaced.

When NOT to Use It#

  • When you need multi-row transactions, unique constraints or strict linearizable reads by default (money balances, inventory with hard limits); use a leader-based or consensus-based database.
  • Small datasets that fit one primary with a standby; the operational cost is not worth it.
  • When the team cannot run regular repairs and reason about conflicts.

How to Implement It#

You almost never implement it yourself; you configure it.

  1. Choose N (3 per data centre is standard) and placement across racks or zones.
  2. Choose consistency per query: LOCAL_QUORUM reads and writes for user-facing data; ONE for tolerant data.
  3. Decide conflict handling: LWW (make sure clocks are synced with NTP and timestamps come from one source), or siblings with merge, or CRDT types.
  4. Schedule anti-entropy repairs (Cassandra Reaper) more often than the tombstone grace period.
  5. Monitor hints pending, repair progress, read-repair rates and replica disagreement.
  6. Model data per query: leaderless stores reward partition-key design (see Data Modeling).
TechnologyFits when
Apache CassandraLeaderless wide-column store; multi-DC; tunable consistency
ScyllaDBCassandra-compatible, C++ implementation for lower latency per node
Riak KVKey-value with siblings and CRDTs (smaller community today)
Amazon DynamoDBManaged; not leaderless internally, but offers similar scaling

Trade-offs#

ChoiceGainCostPick when
Quorum R=W=2, N=3Reads see latest writes, tolerates 1 failure2 round trips' worth of waitingDefault for user data
R=1, W=1Lowest latency, highest availabilityStale readsMetrics, logs, caches
Sloppy quorumWrites survive partitionsNo overlap guaranteeAvailability over consistency
Vector clocks + mergeNo lost concurrent writesApp merge logic, siblingsCarts, collaborative data
LWWSimpleLost concurrent updates; clock dependenceOverwrite-style data
Blocking read repairMonotonic quorum readsExtra writes and latency on mismatched readsTables read at QUORUM or LOCAL_QUORUM
Lightweight transactions (Paxos)Linearizable compare-and-set per keyAbout four round trips, poor under contentionUniqueness checks, seat or slot claims
LOCAL_QUORUM in multi-DCLocal latency, survives a zone lossCross-region readers see eventual consistencyUsers pinned to a home region
CRDT typesAutomatic, correct mergesLimited to supported types, metadata overheadCounters, sets, collaborative state

Common Pitfalls#

  • Believing R + W > N means strong consistency in all cases.
  • Never running repair, so deleted data reappears after tombstones expire.
  • Using LWW with unsynchronised client clocks, letting an old write win.
  • Using ALL for safety, then losing availability whenever one node restarts.
  • Reading at ONE immediately after writing at ONE and expecting to see the write.
  • Treating a failed quorum write as "not applied" and retrying with a new timestamp, creating a duplicate or reordered write.
  • Letting hints expire for a node that was down past max_hint_window and never repairing it.
  • Using QUORUM instead of LOCAL_QUORUM in a multi-region cluster and paying cross-region latency on every request.
  • Union-merging siblings without tracking removals, so deleted items keep coming back.

Real-World Examples#

The Dynamo paper (DeCandia et al., SOSP 2007) describes Amazon's shopping cart store with consistent hashing, sloppy quorums, hinted handoff, Merkle trees and vector clocks; it typically used N=3, R=2, W=2.

Apple, Netflix and Discord (before moving to ScyllaDB in 2022) have described running large Cassandra clusters for high write volumes.

Amazon Aurora's storage layer applies quorum ideas inside a leader-based database: six copies across three availability zones with 4-of-6 write and 3-of-6 read quorums, so it survives a zone loss. Cassandra operators widely use Cassandra Reaper to run continuous subrange repairs, because skipping repair within the tombstone grace period resurrects deleted data.

In the Interview#

Handling quorums in an interview#

Recognise the prompt. Quorums come up when the problem says "highly available writes", "must keep working if a node or zone fails", "multi-region with local latency", or when you are asked to design a key-value store. In those cases, state the parameters and their consequences in one breath: "Three replicas per region across three zones, writes and reads at LOCAL_QUORUM. Any one zone can fail without errors, reads see the latest local write, and p99 latency is that of the second-fastest replica."

Show you know the limits. Two sentences show depth. First: "R + W > N gives overlap, not linearizability. Partial failed writes and concurrent writes can still produce anomalies, so for the username uniqueness check I'd use a lightweight transaction." Second: "With sloppy quorums, the overlap guarantee disappears during partitions, which is fine for carts and not fine for inventory."

Explain convergence as layers. Interviewers often ask, "a replica was down for an hour, what happens?" Answer with the layers: hints replay the missed writes when it returns, read repair fixes keys as they are read, and scheduled Merkle-tree repair, running within the tombstone grace period, guarantees everything converges and deletes stay deleted.

Conflicts. Say how concurrent writes are resolved, per data type. "Profile fields use last-write-wins, because concurrent edits are rare and losing one is acceptable. The cart uses an OR-Set so concurrent adds and removes merge correctly. Counters use a PN-counter or are aggregated elsewhere."

Avoid proposing leaderless replication for money or hard-limit inventory, using ALL "for safety", or quoting R + W > N as "strong consistency" without qualification.

Deep Dive: Why quorums are not linearizable, and how to measure stalenessShow

Anomalies with strict quorums. Suppose a write reaches only one replica before the coordinator crashes; the client sees an error, but the value exists on one node. A later read might or might not see it depending on which replicas answer, so a "failed" write can appear and then disappear. Also, two concurrent readers can see different values while a write is in flight. Linearizability needs read repair to complete synchronously before returning (as in the ABD algorithm) and careful handling of concurrent writes; most Dynamo-style databases do not pay that cost by default.

Probabilistically bounded staleness (PBS). Research from Berkeley (Bailis et al., 2012) modelled how often partial quorums return stale data, finding that with typical latency distributions, R=1, W=1 often returns the latest value within tens of milliseconds of a write. Measuring staleness in your own cluster helps choose levels on evidence.

Dotted version vectors and sibling explosion. Plain version vectors keyed by client ID grow without bound; keyed by server, they can create false conflicts. Riak moved to dotted version vectors to track causality precisely and avoid sibling explosion.

Deep Dive: Quorum systems theory, and making quorums linearizableShow

Quorum systems in general. A quorum system is a collection of subsets of servers (quorums) such that any two intersect. Majorities are the classic example, but not the only one. In a grid quorum, n servers are arranged in a sqrt(n) by sqrt(n) grid, and a quorum is one full row plus one element from every row, so any two quorums intersect. Grid quorums have size about 2 sqrt(n) rather than n/2. Naor and Wool ("The Load, Capacity, and Availability of Quorum Systems", SIAM Journal on Computing, 1998) formalised the trade-off. The load of a system is how often the busiest server must take part in a quorum. Majorities have load about 1/2, while grids achieve about 1/sqrt(n), so each server does less work. But small quorums are less available, because fewer failures can block every quorum. No quorum system has both very low load and very high availability, which is why practical systems use small replica groups (3 or 5) with majorities and scale out by partitioning instead.

Read and write quorums can differ. If only reads must see writes, you need R + W > N. If writes must also be ordered against each other, so two concurrent writes cannot both commit unseen by each other, you also need W + W > N, which is a write majority. Aurora's 4-of-6 writes and 3-of-6 reads satisfy both. A W = 1 system satisfies neither for write-write conflicts, which is why such systems need timestamps or version vectors to sort out concurrent writes afterwards.

ABD: linearizable registers from quorums. Attiya, Bar-Noy and Dolev ("Sharing Memory Robustly in Message-Passing Systems", JACM 1995) showed how to build a linearizable read/write register on top of majority quorums, without a leader, as long as a majority is up. A write first queries a majority for the highest timestamp, then writes the value with a higher timestamp to a majority. A read queries a majority, takes the highest timestamped value, and then writes it back to a majority before returning. That write-back is what prevents a later read from seeing an older value, and it is exactly blocking read repair. ABD costs two round trips per operation. Cassandra's default does not do the write-back on every read, which is why quorum reads are not linearizable in general. Blocking read repair gives a similar effect only when replicas actually disagree.

Probabilistically bounded staleness, made concrete. Bailis and colleagues (VLDB 2012) modelled partial quorums as a race between write propagation and read arrival. With the latency distributions they measured from production systems at LinkedIn and Yammer, an R = 1, W = 1, N = 3 configuration returned the latest value with high probability within a few tens of milliseconds of the write. The probability rose quickly with time. The practical lesson is that "eventual" is often a short window, and you can measure it. Write a key, read it from a random replica after a delay t, and record how often the read is stale. A curve of staleness against t lets you justify ONE for data where a 50 ms window is harmless.

Key Takeaways#

  • Leaderless replication writes to all N replicas and waits for W, reads from R; R + W > N makes read and write sets overlap.
  • R and W are tunable per request; N=3 with quorum reads and writes is the common default.
  • Sloppy quorums and hinted handoff keep writes available during failures, at the cost of the overlap guarantee.
  • Read repair and Merkle-tree anti-entropy bring stale replicas back in sync.
  • Version vectors detect concurrent writes so they can be merged instead of silently lost; this is the Dynamo-style design.
  • A failed quorum write has an unknown outcome. Make writes idempotent and retry with the same version or timestamp.
  • Quorum p99 latency is close to a single replica's p99, because waiting for 2 of 3 hides one slow replica.
  • Pick levels per pair of write and read: LOCAL_QUORUM on both for user data, LOCAL_ONE for tolerant reads, lightweight transactions for uniqueness.
  • Repair every range within gc_grace_seconds (10 days by default), or deletes come back as zombies.
  • Quorum intersection also underlies Raft, Paxos and Aurora. Leaderless stores are one application of it.