Articles

Raft vs Paxos: Consensus Algorithms Compared

Raft and Paxos both let a distributed cluster agree on a value despite failures — Raft trades some flexibility for a design built to be understood.

Chisato Chisato · · 5 min read
An abstract blue network mesh of connected nodes

Raft and Paxos are both consensus algorithms — protocols that let a cluster of machines agree on a single value or sequence of operations even when some machines fail or messages get delayed, without any single machine being a trusted source of truth. Paxos came first and became the theoretical foundation for distributed consensus; Raft was designed later specifically to solve the same problem while being dramatically easier to understand and implement correctly.

Both algorithms solve the same underlying need addressed differently by the CAP theorem’s consistency tradeoffs: how does a distributed system keep multiple replicas agreeing on state — who’s the leader, what value was committed, what order operations happened in — when nodes can crash, restart, or lose network connectivity at any time?

What problem consensus actually solves

Imagine a replicated database with three or five nodes, any of which might crash or become temporarily unreachable. If a client writes a value, every surviving node needs to eventually agree on that value, and the system needs to keep making progress as long as a majority of nodes can still communicate — even if the exact set of reachable nodes changes over time.

This is harder than it sounds, because messages can be delayed, nodes can crash mid-operation and restart with stale state, and the network can partition into groups that can’t talk to each other. A consensus algorithm has to guarantee that the cluster never ends up in a state where two different nodes believe two different, conflicting values were both agreed upon — even under all of those failure conditions.

Paxos: the original, hard-to-implement answer

Paxos, first described in the late 1990s, proves that consensus is achievable under these conditions using a majority-quorum voting scheme: a value is only considered “chosen” once a majority of nodes have accepted it, which guarantees that any two majorities overlap in at least one node, and that overlap is what prevents conflicting decisions.

The core algorithm (often called “single-decree Paxos”) reaches agreement on one value through two phases of majority voting — proposers ask for votes, then propose a value, and acceptors respond to both phases. It’s provably correct and remarkably general, but the description most engineers work from is notoriously difficult to map onto a real, production-quality implementation. Real systems need “multi-Paxos” — repeatedly running the protocol to agree on a sequence of operations, such as a replicated log — and the original papers leave much of that extension, along with practical concerns like leader election and log compaction, underspecified. This gap between the formal protocol and a working implementation became something of a running joke in distributed systems circles for years.

Raft: designed to be understandable

Raft, published in 2014, set out explicitly to solve the same problem as multi-Paxos while being easier to teach, easier to reason about, and easier to implement without subtle bugs. It achieves this by decomposing the problem into three relatively independent, well-defined subproblems:

  • Leader election — the cluster elects a single leader responsible for managing the replicated log, using randomized election timeouts to avoid repeated split votes.
  • Log replication — the leader appends new entries to its own log and replicates them to followers, only considering an entry committed once a majority of nodes have stored it.
  • Safety — a set of constraints (an election restriction ensuring only up-to-date nodes can become leader, and rules for how followers handle conflicting log entries) that guarantee the whole system stays consistent even across leader changes and failures.

Where Paxos treats every node as symmetric and lets any node propose a value at any time, Raft is deliberately more structured: there is always at most one leader at a time, and only the leader ever appends new entries to the log. This gives up some of Paxos’s theoretical flexibility in exchange for a design that maps far more directly onto actual code, which is exactly the tradeoff Raft’s authors set out to make.

Raft vs Paxos, side by side

PaxosRaft
PublishedLate 1990s2014
Design goalTheoretical generality and correctness proofUnderstandability and ease of correct implementation
Leader modelSymmetric — any node can proposeStrong single-leader model
Log replicationRequires separate extension (multi-Paxos), underspecifiedBuilt into the core protocol
Common implementationsZooKeeper (via a Paxos-derived protocol called Zab), classic distributed databasesetcd, Consul, CockroachDB, many newer systems
Learning curveSteep, especially for multi-PaxosExplicitly designed to be approachable

In practice, the two provide equivalent guarantees — both are proven to solve consensus correctly under the same failure model (a majority of nodes available, with crash-recovery failures rather than malicious/Byzantine ones). The difference that matters day to day is implementation risk: Raft’s explicit structure has made it the default choice for new systems over the past decade, precisely because subtle Paxos implementation bugs have historically been a real source of production incidents.

Where these algorithms show up

Consensus algorithms sit underneath a lot of infrastructure that gets taken for granted. Systems like etcd (which stores Kubernetes cluster state) and Consul use Raft directly. ZooKeeper, widely used for distributed coordination and configuration in systems like Kafka, uses Zab, a protocol heavily influenced by Paxos’s ideas even though it isn’t a literal implementation of the original algorithm. Distributed SQL databases that need strongly consistent replication — rather than the eventual consistency common in systems built around consistent hashing — typically use Raft or a Paxos variant internally to agree on transaction ordering across replicas.

This is also distinct from the coordination problem solved by two-phase commit, which coordinates a single atomic transaction across multiple participants rather than maintaining an ongoing, fault-tolerant replicated log — the two are often used together in larger systems, with consensus handling replication within a cluster and two-phase commit or the saga pattern coordinating across separately-owned services.

The takeaway

Raft and Paxos solve the same fundamental problem — getting a cluster of unreliable nodes to agree despite crashes and network delays — using the same majority-quorum foundation, but Raft was built specifically to make that solution understandable and implementable without the pitfalls that made multi-Paxos notoriously easy to get subtly wrong. That’s why most new distributed systems built in the last decade default to Raft: not because Paxos is incorrect, but because a correct-and-comprehensible protocol beats a correct-but-treacherous one when real engineers have to build and maintain it.

The Lycoris Team The Lycoris Team · · 4 min read

Read-Your-Writes Consistency Explained

Read-your-writes consistency guarantees a client sees its own writes immediately, even when other clients might not yet. How it's implemented.

#Databases #Distributed Systems #Computer Science
The Lycoris Team The Lycoris Team · · 5 min read

Two-Phase Commit vs. Saga Pattern Explained

Two-phase commit locks resources until every node agrees to a transaction; the saga pattern trades that guarantee for availability using compensating steps.

#Databases #Distributed Systems #Computer Science
Chisato Chisato · · 4 min read

PACELC Theorem Explained: Beyond CAP

PACELC extends CAP theorem by adding a tradeoff that applies even when there's no partition: latency versus consistency. Here's how it works.

#Databases #Distributed Systems #Computer Science