SDSystem DesignConcepts to case studies
System DesignDSA
x
0/311
Part 1: Foundations
Part 2: APIs and Communication
Part 3: Caching
Part 4: Data and Storage
  • Indexing
  • Partitioning
  • Replication
  • Sharding
  • Query Optimization
  • Denormalization
  • Materialized Views
  • Connection Pooling
  • Replication Models
  • Replication Lag
  • Quorum (R + W > N)
  • Shard Keys, Hot Shards and Resharding
  • Cross-Shard Joins
  • Backups, RPO, RTO and Disaster Recovery
  • Point-in-Time Recovery
  • Data Archiving and TTL
Part 5: Architecture
Part 6: Distributed Systems
Part 7: Advanced Data Topics
Part 8: Operations and Security
Part 9: Estimation and Interview Method
Part 10: Case Studies
System Design/Data and Storage/Database Scaling

Quorum (R + W > N)

Ask enough replicas on reads and writes that they must overlap, so you always see the latest write.

⏱ 14 min readAdvancedMust KnowInterview FavouriteHas visualizer
SummaryConceptReal-Life ExampleWhy?Where?How It WorksStepsKey TermsPros & ConsMistakesReal WorldRead NextInterview Q&ACheat-Sheet

01Quick Summary

A quorum is the smallest number of copies that must agree before an operation counts. With N copies of the data, a write waits for W acknowledgements and a read asks R copies.

  • If R + W > N, the group that was written and the group that is read must overlap in at least one copy. So the read can find the newest value.
  • You can tune it: small W means fast writes, small R means fast reads, and majority for both is a balanced choice.
  • It gives a useful guarantee, but not a perfect one. Concurrent writes and some failure shortcuts can still return old data.

02Concept: What is it?

In a leaderless database, there is no boss. Each piece of data is stored on N nodes, called replicas. When a client writes, it sends the value to the replicas and waits until W of them say "done". The other replicas get the value a little later. When a client reads, it asks R replicas and takes the answer with the newest version.

Here is the key idea. Suppose N = 5, W = 3 and R = 3. A write reached 3 replicas. A read asks 3 replicas. Two groups of 3 taken from 5 must share at least one member (3 + 3 = 6, which is more than 5). That shared replica has the new value, and the read sees it. In short: if R + W > N, a read overlaps the latest successful write.

Two groups that must overlap
✍️WriteW = 3
→↓
Anew
Bnew
Cnew + read
Dold
Eold
←
👀ReadR = 3 (C, D, E)
Has the new value In both groups Still old
N = 5, W = 3, R = 3. The write group and the read group share at least one replica.
🧠The one formula
R + W > N means every read group touches every write group. It does not matter which replicas were chosen.

03Real-Life Example

🍵The Five Notice Boards
A town has five notice boards, each with a copy of the same list. To change the list, a clerk must update at least three boards before saying it is done. To read the list, a visitor checks any three boards and trusts the one with the newest date. Because the clerk changed three and the visitor checks three out of five, at least one board in the visitor's group has the new list. If two boards are broken, the clerk can still reach three and the visitor can still check three, so the town keeps working.
Notice boards
Quorum
Five boards
N = 5 replicas
Clerk must update three before saying done
W = 3
Visitor checks three boards
R = 3
Any 3 + any 3 of 5 share a board
R + W > N, so the groups overlap
Trust the board with the newest date
Return the highest version
Two boards broken, town still works
Tolerates N - W failures for writes
Fixing a stale board when a visitor spots it
Read repair
Tuning the dials
W = 5, R = 1
Fast reads
Slow writes
1 down blocks writes
W = 3, R = 3
Balanced
2 down is OK
W = 1, R = 5
Fast writes
Slow reads
1 down blocks reads
N = 5. Different choices of W and R trade write speed, read speed and failures survived.

04Why Do We Need It?

🧮A clear rule
One small formula tells you whether a read is guaranteed to see the last write.
🎛️Tunable
Change W and R per workload: fast reads, fast writes, or balanced.
🛡️Survive failures
The system keeps working while enough replicas are up, with no single leader to lose.
⚖️A dial for consistency
Raise W and R for stronger guarantees. Lower them for speed and availability.
🌐Fits leaderless stores
It is the core of Dynamo-style databases such as Cassandra and Riak.
🗣️An interview favourite
R + W > N is a classic question with a short, clear answer.
Make the read group and the write group big enough to overlap, and a read cannot miss the latest write.

05Where Do We Use It?

🪐Cassandra
You pick a consistency level per query, such as ONE, QUORUM or ALL. Quorum means a majority of the replicas.
🔑Dynamo-style stores
Riak and DynamoDB-style systems use the same read and write quorum idea (DynamoDB hides the settings behind its own options).
🗳️Consensus systems
Raft and Paxos need a majority to commit and to elect a leader. The same overlap idea keeps them safe.
📦Replicated storage
Distributed file and object stores often write to a majority of copies.
🔒Coordination services
Systems like ZooKeeper and etcd answer from a majority of servers.
📨Message logs
Kafka producers can ask for acknowledgement from all in-sync replicas before a write counts.

06Types / Parts / How It Works

Common settings for N = 3

WRR + W > N ?Behaviour
11No (2 is not above 3)Fastest, but a read can miss the latest write
22Yes (4 is above 3)Majority for both. Balanced. One replica can be down.
31Yes (4 is above 3)Fast reads, slow writes. A write fails if any replica is down.
13Yes (4 is above 3)Fast writes, slow reads. A read fails if any replica is down.

How many failures can you survive?

OperationNeedsFailures tolerated
WriteW replicas upN - W
ReadR replicas upN - R
Both at oncemax(W, R) replicas upN - max(W, R)
📝Latency follows the slowest member
A write is done when the W-th fastest replica answers, and a read when the R-th does. Asking more replicas means waiting for slower ones, so large W or R raises latency.

What happens after a write that only reached W replicas?

  • Read repair: a read notices a replica with an old version and writes the newer one back to it.
  • Hinted handoff: if a replica was down, another node holds the write and hands it over later.
  • Anti-entropy: a background job compares replicas (often with Merkle trees) and fixes differences.
Majority quorum
N = 3majority 2
N = 5majority 3
N = 7majority 4
For N replicas, a majority is floor(N / 2) + 1. Any two majorities share a replica.
VisualizerSet N, W and R, take replicas down, then write and readTry N = 5, W = 3, R = 3 and read with the slowest replicas: the groups overlap. Then lower W to 2 and watch a read return stale data. Click replicas to take them down.
Which replicas answer the read?
Click a replica to take it down or bring it back. Green = in the write group. Cyan ring = asked by the read. Amber ring = both.
R + W > N ?
yes
3 + 3 = 6 vs 5
Overlap (min)
1
replicas shared by any read and write group
Write survives
2 down
needs W up
Read survives
2 down
needs R up
Write time
-
slowest in the group
Read time
-
slowest in the group
N = 5 copies. A write needs W = 3 acknowledgements, a read asks R = 3 replicas. R + W = 6 is above N, so every read overlaps the last write in at least 1 replica. Click a replica to take it down.

A simplified model with no random numbers: the write is acknowledged by the fastest W replicas that are up, and the read asks the fastest or the slowest R that are up. Reply times are illustrative. A quorum alone does not give perfect (linearizable) behaviour: concurrent writes, sloppy quorums and clock-based tie-breaks can still cause surprises.

07How to Use It / Steps / Implementation

Picking W and R

  1. 1
    Choose N
    Three is a common start. It survives one failure with a majority. Five survives two, with more cost.
  2. 2
    Decide if you need the overlap
    If a read must see the latest write, make R + W greater than N. If staleness is fine, you may use smaller values for speed.
  3. 3
    Pick for your workload
    Read-heavy: small R and larger W. Write-heavy: small W and larger R. Mixed: a majority for both.
  4. 4
    Check availability
    Count how many replicas can be down before reads or writes fail, and compare it with what you expect.
  5. 5
    Include a version for every value
    The read needs a version number or a timestamp to pick the newest answer. Vector clocks or version vectors handle concurrent writes.
  6. 6
    Run repair
    Keep read repair, hinted handoff and background anti-entropy on, so replicas that missed a write catch up.
  7. 7
    Test failures
    Take replicas down and check that reads and writes behave as your numbers say.
⚠️A quorum is not perfect consistency
Even with R + W > N a read can return old or odd data if two writes are concurrent, if the system uses a sloppy quorum (writes go to stand-in nodes during a failure), if a write only half-succeeded, or if clock-based tie-breaks drop a write. It is not the same as linearizability.
💡Majority in both places
W = R = floor(N / 2) + 1 is a simple default. It tolerates a minority of failures for both reads and writes and always overlaps.

08Key Terms to Know

TermMeaning in easy words
NThe number of replicas that hold a copy of each item
W (write quorum)How many replicas must acknowledge a write
R (read quorum)How many replicas a read asks
QuorumThe minimum group that must agree, often a majority
MajorityMore than half: floor(N / 2) + 1
OverlapA replica that is in both the write group and the read group
Read repairFixing an out-of-date replica when a read finds it
Hinted handoffHolding a write for a down node and delivering it later
Sloppy quorumAccepting a write on stand-in nodes when the usual ones are down
Anti-entropyA background job that compares replicas and repairs them
LinearizabilityThe strongest rule: operations look as if they happen one at a time, in real-time order

09Pros, Cons and Trade-offs

✅ Pros
  • A simple rule gives a clear consistency guarantee
  • Tunable per workload or even per query
  • No single leader to fail
  • Keeps working while enough replicas are up
  • Fits large, spread-out systems
⚠️ Cons
  • Not as strong as linearizability on its own
  • Larger quorums raise latency
  • Needs versions and repair to work well
  • Sloppy quorums and concurrent writes weaken the guarantee
  • Operations can fail when too many replicas are down

Trade-offs

ChoiceWe gainWe lose
Bigger WSafer, more replicas have the writeSlower writes, fewer failures tolerated
Bigger RReads are more likely to be freshSlower reads, fewer failures tolerated
R + W > NReads overlap the last writeMore waiting on every operation
R + W <= NFast and highly availableReads can be stale
Larger NMore safety and more read capacityMore cost, more copying
Sloppy quorumWrites succeed during failuresA weaker guarantee until hints are delivered

10Common Problems and Mistakes

Common mistakes

  1. Thinking a quorum means strong consistency. It guarantees overlap, not a perfect order of all operations.
  2. Using R = 1 and W = 1 and expecting fresh reads. 1 + 1 is not greater than 3.
  3. Forgetting how many nodes must be up. With W = N a single failed replica stops all writes.
  4. Relying on timestamps. Last-write-wins by clock can keep the wrong value when clocks differ.
  5. Ignoring concurrent writes. Two writes that did not see each other need versions or merge rules.
  6. No repair. Replicas that missed writes stay stale until read repair or anti-entropy runs.

Things to watch

🕳️Failed writes that leave traces
A write that reached fewer than W replicas is reported as failed, but some replicas may keep it and a later read can return it.
🧩Sloppy quorums
During a failure, stand-in nodes take writes. The overlap guarantee returns only after hints are handed back.
⏰Clock skew
Version choice by timestamp can pick the wrong value if machines disagree about time.
🐢Slow replicas
A quorum waits for the slowest member of the group, so one slow node can drag tail latency.

11Real-World Examples

🪐Cassandra
Per-query consistency levels (such as ONE, QUORUM, ALL) are a direct form of choosing R and W.
🔑Dynamo design
The Dynamo style popularised tunable N, R and W in a highly available key-value store.
🗳️Raft and Paxos
Both require a majority to commit, which is a quorum with R and W each being a majority.
🧭etcd and ZooKeeper
Cluster metadata is answered by a majority so it stays correct during failures.
📨Kafka
Setting acknowledgements to all in-sync replicas, with a minimum number of them, is a quorum-style rule.
🌍Multi-region storage
Writes that wait for a majority of regions survive the loss of one region.
📝Note
Product names, settings and defaults change between versions. Check the documentation of your database.
Mini case: a settings store with 5 replicas
🖥️App
→↓W = 3 / R = 3
N1
N2
N3
N4down
N5down
Up Down
Writes need 3 acknowledgements and reads ask 3 replicas. Two replicas can be down and the store keeps working.

12Related Topics to Read Next

Replication Models→

Quorums are how leaderless replication decides when an operation is done.

Consistency Models→

What a quorum does and does not promise.

CAP Theorem→

Quorum settings are a practical dial between consistency and availability.

BASE and PACELC→

A fuller view that also counts latency, which a quorum choice changes.

Key-Value Databases→

Where tunable quorums are most common.

Wide Column Databases→

Cassandra-style stores let you pick the level for each query.

Consensus Algorithms→

Majority quorums keep Raft and Paxos safe.

13Interview Questions with Short Answers

14Quick Revision Cheat-Sheet

  • ✔N, W, R: N copies, a write needs W acks, a read asks R.
  • ✔Rule: if R + W > N, a read overlaps the latest successful write.
  • ✔Majority: floor(N / 2) + 1. Any two majorities overlap.
  • ✔Tuning: small R = fast reads, small W = fast writes, majority = balanced.
  • ✔Failures: writes survive N - W down, reads survive N - R down.
  • ✔Repair: read repair, hinted handoff, anti-entropy.
  • ✔Careful: not linearizability. Concurrent writes, sloppy quorums and clocks can still bite.
  • ✔One line: “Ask enough copies on reads and writes that they must share one, and a read cannot miss the latest write.”
← Previous
Replication Lag
Next →
Shard Keys, Hot Shards and Resharding