Skip to content

Quorum

1. What is it? (2-3 lines)

A Quorum is the minimum number of participating nodes in a distributed cluster that must successfully process and acknowledge a read or write operation before the operation is declared successful, ensuring strong consistency without total cluster agreement.

2. Why does it exist?

In a distributed network, requiring 100% of nodes to acknowledge a write before returning success degrades availability (if 1 server is down, writes fail). Conversely, writing to only 1 node creates stale reads. Quorum math guarantees that read and write node sets overlap on at least 1 node, ensuring linearizable consistency while tolerating node crashes.

3. Where is it used?

  • Leaderless NoSQL Stores: Apache Cassandra, Amazon DynamoDB (R + W > N).
  • Consensus Protocols: Raft / Paxos (Majority Quorum = floor(N/2) + 1).
  • Distributed Lock Managers: ZooKeeper, etcd, Redis Redlock.

4. How does it work? (simple flow)

  1. Quorum Variables:
  2. \(N\) = Total Replication Factor (number of nodes storing a copy of the data).
  3. \(W\) = Write Quorum (number of nodes that must ACK a write).
  4. \(R\) = Read Quorum (number of nodes that must respond to a read).
  5. Quorum Inequality (\(R + W > N\)):
  6. If \(R + W > N\), the read set and write set are mathematically guaranteed to overlap on at least one node containing the latest timestamped value (Strong Consistency).
  7. Quorum Operation:
  8. Client sends write to \(N\) nodes; waits for \(W\) ACKs \(\implies\) Returns success.
  9. Client queries \(R\) nodes; compares timestamps \(\implies\) Returns value with newest timestamp (Read Repair fixes stale nodes).

5. Advantages

  • Tunable Consistency: Adjust \(R\) and \(W\) per query to balance latency, availability, and consistency.
  • High Fault Tolerance: System stays 100% operational as long as \(W\) or \(R\) nodes are healthy.
  • Eliminates single points of failure in leaderless multi-master architectures.

6. Limitations

  • Sloppy Quorums & Hinted Handoff: If \(R + W \le N\), systems allow stale reads (eventual consistency).
  • Concurrent writes to overlapping quorums require timestamp resolution (Last-Write-Wins or Vector Clocks).
  • Network latency is bounded by the slowest node in the quorum set.

7. Common interview questions (10)

  1. Explain the Quorum Inequality formula (\(R + W > N\)) and why it guarantees strong consistency.
  2. How does a Majority Quorum (\(Q = \lfloor N/2 \rfloor + 1\)) handle node failures in Raft/Paxos?
  3. How many node failures can a 5-node cluster vs a 6-node cluster tolerate under Majority Quorum rules?
  4. What is the difference between a Strict Quorum and a Sloppy Quorum in Apache Cassandra?
  5. How does Read Repair work during a Quorum Read in Cassandra or DynamoDB?
  6. How do you configure Cassandra for High Read Throughput (W=QUORUM, R=ONE) vs High Write Throughput (W=ONE, R=QUORUM)?
  7. What is Hinted Handoff and how does it affect consistency during node outages?
  8. Why are cluster node counts typically odd numbers (3, 5, 7) instead of even numbers (4, 6)?
  9. How does Split-Brain occur if a network partition prevents forming a Majority Quorum?
  10. How do Local Quorums work in Multi-Region Cassandra clusters (LOCAL_QUORUM)?

8. Common misconceptions

  • Misconception: Quorum requires 100% node agreement. Fact: Quorum requires only a subset (\(W\) or \(R\)) of nodes; Majority Quorum requires only \(\lfloor N/2 \rfloor + 1\) nodes.
  • Misconception: 6 nodes tolerate more failures than 5 nodes. Fact: Both a 5-node cluster (\(\text{majority}=3\)) and a 6-node cluster (\(\text{majority}=4\)) can tolerate exactly 2 node failures!

10. 30-second cheat sheet

  • Golden Rule: \(R + W > N \implies\) Strong Consistency (Overlap Guaranteed).
  • Majority Quorum: \(Q = \lfloor N/2 \rfloor + 1\). 5-node cluster needs 3 ACKs (tolerates 2 failures).
  • Cassandra Tuning:
  • W = QUORUM, R = QUORUM \(\implies\) Strong Consistency.
  • W = ONE, R = QUORUM \(\implies\) High Write Speed, Stale Reads.
  • Odd Cluster Size: Always use 3, 5, or 7 nodes to maximize fault tolerance per server.