Skip to Content
TheCornerLabs Docs
DocsSystem DesignGrokking Scalable Systems for InterviewsConsistency and ReplicationWhat Is Quorum (N, R, W), And Why Does R + W N Give Strongly Consistent Reads

Quorum (N, R, W) is a mechanism in distributed databases where data is replicated to N nodes, and each read or write operation must get responses from at least R or W of those nodes respectively; requiring R + W > N guarantees that every read will include at least one up-to-date replica, thus providing strongly consistent results.

What Is Quorum in Distributed Systems?

In distributed systems, a quorum is the minimum number of nodes that must agree or respond for an operation (like a read or write) to be considered successful.

The term quorum originally comes from the non-technical context of meetings and voting. It means having enough members present to make a decision.

By analogy, in a cluster of database nodes, a quorum ensures enough replicas agree on a value so that the data is consistent.

Quorum (N, R, W) specifically refers to a tunable consistency model often used in NoSQL databases  (for example, in Apache Cassandra or Dynamo-style databases). It involves three key parameters:

  • N (Replication Factor): the total number of replicas that store copies of the data. For example, if N = 3, there are three copies of each piece of data on three different nodes.

  • R (Read Quorum): the number of replica nodes that must respond to a read operation before the read is considered successful. This is sometimes called the read consistency level. A larger R means the read queries more nodes to verify the data (increasing consistency but also read latency).

  • W (Write Quorum): the number of replica nodes that must acknowledge a write operation for it to be considered successful. This is the write consistency level. A larger W means the system waits for more nodes to save the data (improving consistency but potentially adding write latency).

By choosing values for R and W (out of N total replicas), one can tune the consistency vs availability  trade-off of the system.

For instance, requiring acknowledgments from all N replicas (i.e. W = N for writes or R = N for reads) gives the highest consistency but lowest availability, while requiring only one replica (R = 1 or W = 1) maximizes availability at the cost of potential stale data.

Quorum configurations allow a middle ground that can achieve strong consistency without always having to wait for every single replica.

1761733348851013 Image scaled to 65%

Strong Consistency with R + W > N

In quorum consensus, strong consistency is guaranteed if the chosen R and W values satisfy the rule R + W > N.

This condition means that the sets of nodes involved in a write and a subsequent read must overlap.

At least one node that participated in the successful write will also be consulted during the read.

As a result, the read operation will always see the most recent write (or at least detect its presence), ensuring no stale (out-of-date) data is returned.

Why is overlapping important?

Imagine a distributed database with N replicas for each piece of data.

When a write occurs, it might not instantly reach all N nodes (due to asynchronous replication or some nodes being down).

However, if the write was confirmed by W nodes, those W nodes have the latest value.

Later, if a read query asks R nodes for the data, and R + W > N, mathematically, there is at least one node common between the write group and the read group.

That common node has the latest data, so the read operation can obtain the up-to-date value from it (or at least notice a newer timestamp/version). This overlap guarantees that the read will not unknowingly get only stale copies.

To put it another way, R + W > N ensures that a read quorum and a write quorum cannot be completely disjoint sets of nodes.

There’s always at least one replica that “witnessed” the most recent write and will respond to the read.

The system can then return the latest value (for example, by using timestamped writes and choosing the newest version) and even update any stale replicas in the process (a technique known as read repair in some databases).

Conversely, if R + W <= N, it’s possible for a read to happen entirely on nodes that did not get the latest write.

In that case, the read might return outdated data because its quorum of R nodes had no overlap with the W nodes that acknowledged the write.

The best such a system can guarantee is eventual consistency (the data will converge eventually, but a recent read may not see the most recent write).

This is why the rule R + W > N is critical for strong consistency. It forces overlap and eliminates the scenario of “dirty reads” or stale data being read without detection.

Example: Quorum in Action

To make this concrete, consider an example scenario with a replication factor of N = 3 (three replicas for each data item):

  • Strongly Consistent Setup: Suppose we set W = 2 and R = 2. This means any write must be confirmed by 2 out of the 3 nodes, and any read will query 2 out of 3 nodes. Here R + W = 2 + 2 = 4, which is > N (3), satisfying the quorum condition. If a client writes a new value, at least 2 nodes will have that value. A subsequent read will ask 2 nodes; even in the worst case, at least one of those 2 will be one of the nodes that has the latest value (because 2 + 2 > 3 guarantees overlap). Thus, the read will retrieve the latest value (and can update the stale replica if one of the two had old data). In fact, DataStax (Cassandra) documentation confirms that with N=3, using QUORUM for both reads and writes (which effectively means R=2, W=2) “will result in strong consistency.”. This configuration is often used when strong consistency is desired.

  • Eventually Consistent Setup: Now consider W = 1 and R = 1 for N = 3. A write will return success after only one node has the data, and a read will fetch from only one node. Here R + W = 1 + 1 = 2, which is <= N. In this case, a client could write a value (only one node has it), and immediately do a read from a different node that hasn’t received the update; that read would return the old value, i.e. stale data. There was no overlap between the one node written and the one node read. The system is only eventually consistent in this scenario: if no further writes happen, the other replicas will eventually get the update (through background synchronization), but a read right after the write might not be up-to-date. This is the trade-off when R+W is too low. You gain speed and availability, but risk consistency.

  • Balanced Quorum Setup: Many distributed databases offer a quorum or majority level (often called QUORUM in Cassandra) where R and W are chosen as a majority of N (roughly N/2 + 1). For example, with N = 3, a majority is 2 (since 3/2 + 1 = 2.5, rounded down to 2). So R = 2, W = 2 (as above) is a majority quorum. With N = 5, majority would be 3 (since 5/2 + 1 = 3.5, use 3). If N = 5, using R = 3 and W = 3 (both majorities) gives R + W = 6 > 5, ensuring strong consistency. In fact, a system with N=5 that writes to any 3 nodes and reads from any 3 nodes will always have at least one node in common that has the latest data. This configuration can tolerate up to 2 node failures while still maintaining consistency (since even with 2 down, 3 out of 5 can still respond). It’s a popular choice for balancing reliability and performance.

Why R + W > N Matters (Importance and Use Cases)

The quorum approach to consistency is important because it allows tunable consistency.

Systems like Apache Cassandra, Amazon DynamoDB, Riak, and others based on the Dynamo model let clients choose R and W per operation or per table.

This means developers can decide, for each query, whether they want it to be strongly consistent or if they can tolerate eventual consistency in exchange for lower latency or higher availability.

For instance, a finance application might use R+W > N for critical account updates (so that reads are always current), whereas a social media feed might use a lower consistency level to favor speed, accepting that some reads might be slightly stale.

From an interview preparation and learning standpoint, understanding quorum consensus (N, R, W) is valuable for grasping how distributed databases handle the CAP theorem  trade-offs.

It demonstrates one way to achieve consistency (the “C” in CAP) even in systems that don’t have a single leader coordinating all writes.

By using quorums, the system can remain highly available (continue operating even if some nodes fail) and still keep data consistent as long as the quorum condition is met.

In practice, a quorum read/write system can tolerate up to N - (R or W) node failures without losing consistency.

For example, with majority quorums, the system can survive the failure of nearly half the replicas and still function correctly.

Some real-world notes on quorum usage:

  • In Apache Cassandra, consistency levels like ONE, QUORUM, and ALL correspond to different R and W values. The QUORUM level typically means R or W = ⌈N/2⌉ + 1 (majority). Cassandra’s documentation notes that if you “write at QUORUM and read at QUORUM”, you get strong consistency. If you drop below that (say, write at ONE and read at ONE), you only have eventual consistency . Cassandra even performs read repair in the background. If a quorum read finds a newer value on one node and stale values on others, it can update the stale ones to fix divergence.

  • In systems like Amazon DynamoDB or Riak, similar principles apply. They allow specifying R and W values for operations. The Dynamo white-paper popularized the notation (N, R, W) and this quorum approach for eventual consistency tunable to strong consistency by appropriate settings.

  • The concept of quorum isn’t limited to databases. It appears in distributed algorithms (like Raft or Paxos consensus) and even distributed locking. In those contexts, a quorum (often a majority) of nodes must agree on a value or grant a lock, to avoid split-brain decisions. The underlying principle is the same: requiring a certain threshold of agreement to ensure one group’s decision overlaps with any other group’s decision.

In summary, R + W > N is the magic formula for strongly consistent reads in a replicated data system.

It is crucial for ensuring that whenever you read data, you’re seeing the latest write.

This comes at the cost of potentially higher latency (because R and W are larger numbers, meaning waiting for more nodes to respond) or reduced availability (if enough nodes are down such that R or W cannot be met, the operation fails).

System designers choose these values based on application needs. For example, an e-commerce order system might favor consistency (R+W>N) to avoid showing incorrect stock levels, while a cached profile info service might allow R+W<=N to always return quickly even if slightly outdated.

Last updated on