SYS ARCHITECTLearning Platform
Settings
Theory

Quorum (Majority Voting)

πŸ“‹ Overview

In distributed systems, a Quorum is the minimum number of nodes that must agree on an operation for it to be considered successful. It is the fundamental mechanism used to ensure Consistency and Partition Tolerance (CP). By requiring a majority of nodes to acknowledge a write or verify a read, the system prevents "Split-Brain" scenarios where different parts of a cluster make conflicting decisions.


πŸ—οΈ Core Principles & Characteristics

  • Majority Rule: Typically defined as $Q = \lfloor N/2 \rfloor + 1$. For a 5-node cluster, the quorum is 3.
  • Read/Write Quorum Formula: For strong consistency, the sum of Read Quorum ($R$) and Write Quorum ($W$) must be greater than the total number of nodes ($N$): $R + W > N$.
  • Overlap Guarantee: The formula ensures that at least one node in the Read Quorum has the latest version of the data from the Write Quorum.

βš–οΈ Trade-offs: Pros & Cons

  • Pros: Guarantees strong consistency; prevents data loss during node failures; allows the system to continue operating as long as a majority is alive.
  • Cons: Availability Risk: If more than half the nodes go down, the system becomes unavailable for both reads and writes; Latency: Operations are only as fast as the slowest node in the quorum.

🌍 Real-World Implementation

  • Cassandra: Allows users to tune the quorum per request (e.g., QUORUM, LOCAL_QUORUM, ALL, ONE).
  • Zookeeper/Etcd: Require a quorum for leader election and for committing any changes to the replicated state.
  • Raft/Paxos: Use quorum as the core voting mechanism to ensure only one leader exists and only one log entry is committed at a time.

πŸ’‘ Interview "Gotchas" & Tips

  • The "Split-Brain" Scenario: If you have 4 nodes and the network splits 2v2, neither side can reach a quorum of 3 ($4/2 + 1$). The system stops. This is goodβ€”it prevents inconsistent data from being written to both sides.
  • Odd vs. Even Nodes: Clusters usually have an odd number of nodes (3, 5, 7). Why? A 4-node cluster still requires 3 for a quorum, but can only tolerate 1 failure ($4-3=1$). A 3-node cluster also tolerates 1 failure but with less hardware.
  • Eventual Consistency: If you set $R=1$ and $W=1$ in a 3-node cluster ($1+1 < 3$), you lose strong consistency but gain high speed/availability.

πŸ“ Suggested Architecture Primitives

  • Read-Write Split: Configuring different quorum levels for different business priorities.
  • Witness Nodes: Nodes that participate in voting but don't store data (to save costs while maintaining quorum).
  • Dynamic Reconfiguration: Allowing the cluster to change its "total node count" ($N$) at runtime to handle permanent node additions/removals.
Canvas