arthrop0d

Brief articles on varied topics.

Quorum Reads and Writes in Replicated Datastores

distributed systemsdatabases

A quorum read or write is an operation that waits for responses from a configured number of replicas before succeeding. In a replicated datastore, N is the number of copies in the operation’s replica set, R is the number of replicas a read consults, and W is the number of replicas that must acknowledge a write.

These thresholds let a system choose a point between consistency and availability: waiting for more replicas gives stronger evidence that data is current, but makes operations more likely to fail when nodes are down or slow.

The problem replication creates

Replication keeps data available when a machine fails and can spread read or write traffic across machines. But copies do not update at exactly the same time. A write might reach two replicas while a third is temporarily disconnected. A read sent to that third replica could return the previous value.

Without a quorum rule, “the database accepted my write” and “the next read returns my write” are separate, unpredictable events. The client might contact different replicas and observe different versions.

A quorum gives the datastore a rule for how much of the replica set must participate. You may already have seen this in a consistency setting, a message such as “not enough replicas,” or a timeout that says the requested consistency level could not be met.

What N, R, and W mean

Suppose a key has three replicas:

The coordinator—the node that receives the client request—usually sends the operation to all replicas that should hold the key. It counts acknowledgements until it reaches W for a write or has R responses for a read. The remaining replicas may catch up asynchronously.

For a read, the datastore normally compares the returned versions and selects the newest one, rather than returning whichever response arrived first. A version is metadata that lets replicas decide which value supersedes another, such as a sequence number, logical timestamp, or conflict-resolution marker.

The key quorum relationship is:

If R + W > N, every successful read overlaps the replicas that acknowledged every successful write.

With N = 3, R = 2, and W = 2, any two-replica read shares at least one replica with any two-replica write. That shared replica should have the write’s version, so the read can discover it and return that version.

This is why the relationship is often described as protecting read-after-write visibility: after a successful write, a later successful read is guaranteed to include a replica that knew about that write, assuming the datastore’s version comparison and conflict-resolution rules work correctly.

The relationship is not magic, and it does not mean every read returns the same value under every circumstance. It depends on the read asking the same replica set, the write being considered complete only after W acknowledgements, and the read choosing the newest valid version. Concurrent writes can still conflict, and a datastore may expose different consistency guarantees for operations that overlap in time.

Choosing the thresholds

Common configurations illustrate the trade-off:

Configuration Effect
R = 1, W = 1 Fast and available, but a read can hit a lagging replica.
R = 2, W = 2, N = 3 Both operations tolerate one unavailable replica and satisfy R + W > N.
R = 3, W = 1, N = 3 Writes finish quickly; reads wait for every replica and can find the newest version.
R = 1, W = 3, N = 3 Writes require every replica; reads are fast once the write succeeds.

If R + W <= N, the read and write sets can be disjoint. For example, with N = 3, R = 1, and W = 2, a read could contact the one replica that missed the write. It might return an older value even though the write succeeded.

That is not necessarily a bug. It is the explicit availability choice made by that configuration. A system might accept stale reads for lower latency, or use a stronger read setting only for operations such as checking an account balance.

Failures, lag, and timeouts

A replica can be unavailable—not responding at all—or lagging, meaning it is responding but has not applied recent writes. Quorum settings handle these differently:

Systems often send a missed write to a temporary substitute, called a hinted handoff, or repair an older replica when a later read discovers that it is behind. Read repair is the practice of updating stale replicas as part of serving a read. These mechanisms reduce lag, but they do not change the quorum arithmetic: a read that does not overlap a completed write can still be stale.

Quorums also do not make failed writes disappear cleanly. A client may time out after some replicas accepted the value but before the coordinator reported success. Retrying the write should therefore be safe only if the operation is designed to tolerate retries, commonly through an idempotent write or a request identifier.

What a quorum does—and does not promise

R + W > N is a useful intersection guarantee, not a universal definition of strong consistency. It helps a read find a completed write, but correctness also depends on replica placement, version ordering, conflict resolution, and the datastore’s behavior during partitions.

For example, if two clients write different values concurrently, both may satisfy their W thresholds. The datastore needs a rule—such as last-write-wins, a deterministic version order, or application-level conflict handling—to decide what a later read returns. Quorum settings cannot determine which business value is correct.

The practical question behind a quorum configuration is therefore: how many copies must participate before this operation is allowed to succeed? Increasing R or W improves the evidence that a value is current, while decreasing them improves latency and survival during failures. The right choice depends on whether the application prefers availability and possibly stale data, or failed operations when the datastore cannot establish the required overlap.

← All articles