Concept · Distributed Systems

Quorum

01

Why this matters

In a replicated system, you have N copies of the data. Do you write to all N before returning? Just 1? Somewhere in between? Do you read from all N (slow), or 1 (possibly stale)? The answer is a quorum — a minimum number of replicas that must acknowledge a write (W) or participate in a read (R). Tuning N, W, R independently lets you pick exactly the consistency-availability-latency tradeoff you want per query.

Understanding quorum math is fundamental to Dynamo-style systems (Cassandra, DynamoDB, Riak) and to consensus-based ones (Raft, Paxos).

02

The magic inequality

With N replicas, writes go to W of them, reads query R of them.

If W + R > N, any read is guaranteed to overlap with the latest write — at least one of the R replicas read saw the write, so you get the newest value.

If W + R ≤ N, reads can miss the latest write. That's fine for eventual consistency; catastrophic for a bank ledger.

The magic: you pick W and R per operation based on what you need.

W + R > N = OverlapSVG
N=5, W=3, R=3 → overlap on at least one replica R1 R2 R3 overlap R4 R5 W=3 writes (R1, R2, R3) R=3 reads (R3, R4, R5)
03

Tuning per workload

WRBehaviorUse for
N1Write to all, read from one. Fast reads, slow writes.Read-heavy, strong consistency
1NWrite to one, read from all. Fast writes, slow reads.Write-heavy OK-to-delay reads
⌈(N+1)/2⌉⌈(N+1)/2⌉Both majority. Balanced.General default — Dynamo's "quorum"
11Write one, read one. No overlap guarantee.Eventual consistency OK — counters, cache
00No durability guarantees.Never
04

Deep dive — sloppy quorum

Strict quorum says: writes must go to W of the N home replicas. If a network partition isolates them, writes fail. Good for correctness, bad for availability.

Sloppy quorum (Dynamo): if the home replicas are unreachable, write to any W healthy nodes, marking them as temporary holders. When the network heals, hinted handoff transfers the data back to the real home replicas.

Result: writes keep succeeding during partitions. Reads from the home replicas might temporarily miss recent writes (they're on the temporary holders). Availability ↑, consistency temporarily ↓. Cassandra and DynamoDB both default to sloppy quorum — it's the reason they feel always-up during AWS regional incidents.

Interview answer

"We use quorum reads/writes: W=R=⌈(N+1)/2⌉=3 of N=5 replicas. This guarantees read-your-writes strongly. For latency-critical reads on low-stakes data (e.g. engagement counters), we drop to R=1, accepting eventual consistency."

Quorum N/R/W (Dynamo-style)
# N = total replicas, R = read quorum, W = write quorum
# Consistency iff R + W > N

def write(key, value, replicas, W):
    acks = 0
    for r in replicas:
        try:
            r.put(key, value)
            acks += 1
            if acks >= W: return "ok"
        except Exception:
            pass
    return "failed" if acks < W else "ok"

def read(key, replicas, R):
    results = []
    for r in replicas:
        try: results.append(r.get(key))
        except: pass
        if len(results) >= R: break
    # Return value with latest vector clock; trigger read-repair for stale
    return max(results, key=lambda x: x.version) if results else None

# N=3, R=2, W=2 → tolerates 1 failure per op; strong consistency.
# N=3, R=1, W=3 → fast reads, slow writes.
# N=3, R=1, W=1 → eventual consistency.
05

Real-world

Cassandra

Per-query tunable

Consistency levels: ONE, QUORUM, ALL, LOCAL_QUORUM. Most apps pick LOCAL_QUORUM for reads + writes.

DynamoDB

Implicit quorum

Strong reads query a quorum, eventual reads read one replica. You toggle per request.

Raft / Paxos

Majority quorum mandatory

Commit requires N/2+1 acks. Leader election requires N/2+1 votes. Classic majority overlap theorem.

MongoDB

Write concern + read preference

w: "majority" for writes, readConcern: "majority" for reads. Same quorum pattern wrapped in different vocabulary.

06

Used in problems

News feed uses local-quorum writes for feed entries (durability) + eventual reads for scale. WhatsApp uses quorum writes on the message-persist path. Distributed logging uses quorum for log commit visibility.

Next up