Consensus vs Consistency Models
What you'll learn: How consensus algorithms differ from consistency models, and why both matter in distributed systems.
The Core Distinction
Consensus and consistency are often confused, but they solve different problems:
-
Consensus algorithms answer the question: "How do multiple nodes agree on a single value or decision?" They're about coordinating a specific choice among distributed participants.
-
Consistency models answer: "What guarantees does the system provide about the order and visibility of reads and writes?" They're about the behavior users observe when accessing data.
Think of it this way: consensus is like a voting mechanism that gets everyone to agree on one thing (who's the leader, what's the next log entry). Consistency models describe what happens after decisions are made—how data appears to readers and writers.
How They Relate
Consensus algorithms (like Paxos or Raft) are tools to implement strong consistency models. For example:
- To achieve linearizability, you might use consensus to agree on a total order of operations
- To provide strong consistency across replicas, consensus ensures all nodes commit the same sequence of updates
However, you can have consistency models without consensus:
- Eventual consistency requires no agreement protocol at all—replicas sync lazily
- Causal consistency can use version vectors without needing majority votes
The Key Difference
Consensus solves the coordination problem. Consistency models define the user-facing guarantees. You might use consensus internally to deliver a consistency promise externally.
Key Takeaway: Consensus is a mechanism for agreement among nodes; consistency models are the guarantees your system provides to clients. Consensus can help achieve strong consistency, but they're not the same thing.