Protocol Mechanics: Core Differences
Raft and Paxos are the two dominant consensus algorithms used in distributed systems, yet they approach the problem of achieving agreement across unreliable networks in fundamentally different ways. Understanding their mechanics is essential for engineers designing fault-tolerant swarms of autonomous vehicles, edge computing clusters, or mission-critical control systems.
Paxos, originally formalized by Leslie Lamport, operates through three distinct phases: prepare, promise, and accept. A proposer sends prepare requests with a proposal number to acceptors. Acceptors respond with promises, indicating they will not accept lower-numbered proposals. Only after receiving a quorum of promises does the proposer send accept requests. This two-round protocol ensures that any accepted value is eventually learned by all learners. Paxos is fundamentally asynchronous — it makes no timing assumptions and tolerates arbitrary message delays.
Raft, designed by Diego Ongaro and John Ousterhout, simplifies consensus through a leader-based approach. A single leader is elected, and all state changes flow through this leader. Followers replicate log entries from the leader and commit them once replicated to a majority. Raft's key insight is that strong leadership simplifies reasoning: instead of the complex quorum interactions in Paxos, Raft uses straightforward log replication. However, Raft's safety guarantees depend on election timeouts — a partially synchronous model where message delays are bounded, though not known in advance.
Safety Properties: Ensuring Correctness
Both algorithms guarantee safety — the core requirement that all non-faulty nodes agree on the same sequence of committed values, even under Byzantine message loss and reordering.
In Paxos, safety emerges from the prepare-promise mechanism. When a proposer receives a quorum of promises, it learns about any previously accepted values. It must then propose the highest-numbered value it learned about (or any new value if none were previously accepted). This ensures that if a value was accepted by a quorum in one round, any future quorum will contain at least one member that knows about it, guaranteeing the value propagates forward.
In Raft, safety comes from the log matching property: if two nodes have log entries with the same index and term, then all entries before that point are identical. This is enforced by the leader, which only appends entries to followers' logs and never overwrites or deletes committed entries. The term mechanism acts as a logical clock, ensuring that outdated leaders cannot commit new entries — a critical property for preventing split-brain scenarios.
Consider a concrete example: in a vehicle fleet consensus system, three nodes (V1, V2, V3) must agree on the next waypoint. In Paxos, a proposer might fail after sending prepare requests but before sending accepts. Another proposer can then take over, learning about any in-progress proposals and ensuring continuity. In Raft, if the current leader (V1) fails, a new election occurs, and only a node with a sufficiently up-to-date log can become the new leader, preventing older waypoint decisions from being revived.
Liveness Guarantees: Progress Under Adversity
Liveness means the system makes progress — values are eventually committed and decisions are made. This is where Paxos and Raft diverge significantly.
Paxos guarantees liveness only in partially synchronous systems, not in fully asynchronous ones. If proposers keep conflicting (each starting a new proposal before others finish), the system can livelock indefinitely. Practical Paxos implementations use leader election or randomized backoff to mitigate this, but the theoretical model does not inherently prevent livelock.
Raft also requires partial synchrony but provides stronger liveness through its leader-based design. Once a leader is elected and the election timeout interval elapses without further elections, the leader can make progress unilaterally. Raft's liveness is more predictable: if the leader is stable and message delays are bounded, new entries commit within a bounded number of rounds.
For mission-critical control systems like autonomous vehicles, this difference is profound. A Paxos implementation might experience unpredictable delays if multiple nodes propose conflicting state changes. Raft's leader-based approach allows control software to reason about progress: "If no leader election is happening, commands will commit within time T." This predictability is essential for real-time control loops.
Practical Implications for Swarm Engineering
When building consensus swarms, choose Paxos for systems requiring maximum asynchrony tolerance (e.g., geographically distributed data centers with unpredictable latency). Choose Raft for systems where partial synchrony assumptions are acceptable and simplicity is valued (e.g., edge vehicle clusters in controlled environments).
Both algorithms, however, require careful timeout tuning and deadlock detection mechanisms when deployed in asynchronous environments — topics we explore in subsequent sub-modules.