Why you are doing this at all
People say this sentence in interviews and design reviews every week, and it's wrong.
"We write to a quorum and read from a quorum, so W + R > N, so we have consensus."
You don't have consensus. You have overlap. Here N is the number of copies of each piece of data, W is how many copies must confirm a write, and R is how many you ask on a read. The group that answers is called a quorum. Because W + R is more than N, every read reaches at least one node that saw the last write. That's useful, but it isn't agreement. Two clients can write to the same key at the same moment. Both writes reach a quorum, and both clients are told "success." The system now holds two values, and nothing anywhere records which one came second. Nobody agreed on anything, and every node behaved correctly.
A quorum gives you overlap. Overlap is not agreement. Paxos and Raft are the two best-known consensus algorithms, the methods a group of machines uses to agree. Everything inside them is the machinery that turns the first into the second. Both look complicated because this step needs more care than it seems to.
That's the whole article. Once you understand what overlap gives you and what it doesn't, Paxos stops being intimidating. Paxos is the smallest correct answer to that one gap. Raft is the same answer, arranged so that people can hold it in their heads.
Three different problems that get called one thing
Copying data is replication: how do you get this write onto three machines? The replication article covers it.
Agreeing on one value is consensus. Several machines must all end up believing the same single thing, and must never change their minds about it afterwards. That has to hold even though any of them can crash, and messages can be lost, delayed or delivered out of order. This is the subject here.
Reading without lying is a linearizable read: a read that is guaranteed to see every write that finished before it started. Once a value has been agreed, how does a node answer a question about it without telling you something out of date? This sounds like a footnote, but it's the part that trips up real systems, so it gets its own section.
Consensus is the expensive one, and the cost has a specific shape. Before you can say yes to anybody, you pay at least one network round trip to a majority of the machines. That's why you use it for a small number of important things and not for everything.
When you need it, and when you do not
Use consensus for things where two answers would be a disaster and there aren't many of them per second. That means who the leader is, which machines are in the cluster, what the shard map says, who holds a lock, what the schema version is, and whether a config change has rolled out.
Don't use it for the data path of a high-throughput system. A stream of 500,000 user writes a second doesn't go through one consensus group. A consensus group puts every decision through one leader machine, in order, plus a round trip. CockroachDB and TiKV look as if they do this, but they don't. They run hundreds of thousands of separate small consensus groups instead of one big one. That's a different design, and it comes up later.
The toolkit
The one fact everything rests on
Take five machines. Any group of three is a majority. Now pick any two different majorities. They always share at least one machine.
They have to. Three plus three is six, and there are only five machines, so at least one machine is in both groups.
That's all. Every algorithm in this article rests on this one simple fact, and every mechanism you're about to read exists to get information out of it.
Here's why it matters. If a majority made a decision, then any future majority you talk to must contain someone who knows about it. So you can never make a second, conflicting decision without first running into evidence of the first one, as long as you look.
The whole game is in that last condition: you have to look.
Why W + R > N is not consensus
Now let's be precise about what a Dynamo-style quorum gives you and what it doesn't, because this is the most common misunderstanding in the topic. A Dynamo-style store, such as Cassandra or Riak, copies each key to N replicas and has no leader in charge of the order of writes.
You have three replicas. You write to two of them and call it a success, and you read from two of them. Two plus two is more than three, so your read set and your write set share at least one node, and a read always sees the latest completed write. That's a real guarantee, and it's worth having.
Here's what it doesn't stop.
There were two writes. Both succeeded, both values survive, and nothing anywhere records their order. The system didn't fail. It was never asked to decide.
That's the gap. Overlap tells you that a value exists. It doesn't tell you which value won, because nothing ever ran a competition between them.
Three replicas, W = 2, R = 2 W + R = 2 + 2 = 4 > 3 → every read set meets every write set in >= 1 node → a read cannot miss a completed write yes Two writes accepted concurrently → both reach 2 nodes, both return success → surviving values 2 → nodes that know the order 0 → later reads that can recover the order 0 So the guarantee is about VISIBILITY, not about ORDER. To get order you need something that refuses the second write, or numbers them, and neither is implied by W + R > N. The usual patch is last-write-wins on a timestamp, which picks a winner using clocks you do not control and discards the loser without telling anyone.
Paxos, in plain words
Paxos is the smallest known correct way to close that gap. It has a reputation for being hard. Most of that comes from explanations that start with the proof, so we'll start with the problem instead.
We want several machines to agree on one value, forever. The answer must stay correct if machines crash part way through, and if messages arrive late or out of order. Nobody is given to us as the leader, and anyone may try to propose a value.
Here's the naive attempt. I ask all five machines to accept my value, and if a majority accept it, it's decided. This breaks at once, because two proposers can do it at the same time and each get a different majority. We're back to the previous section.
So Paxos adds a step before proposing. Every attempt carries a number. The numbers are unique, and each new attempt uses a higher one. There are two rounds.
Round one, asking permission. I pick a number, say 5, and send "can I use 5?" to all five machines. This message is called a prepare. A machine says yes if it hasn't already said yes to a higher number. Its yes is called a promise, because it also promises to refuse anything below 5 from then on. And here's the important part: if it has already accepted a value from an earlier attempt, it tells me that value and the number it came with.
Round two, proposing. If a majority said yes, I may propose a value, in a message called accept. But I don't always get to propose my own value. The rule is:
If any of the machines that replied told me about a value they had already accepted, I must propose the one that came with the highest number. Only if nobody reported any value at all may I propose my own.
That one rule is the whole of Paxos's safety. Everything else is bookkeeping.
Here's why it works, using the one fact. If a value was already decided, a majority accepted it. My round-one replies also came from a majority. Those two majorities share a machine, and that machine tells me about the decided value. So I can't propose something different. I'm forced to propose the existing decision again, and that does no harm.
Five machines. Attempt 1 used number 5, attempt 2 uses number 9. Attempt 1 got its value accepted by a majority machines that accepted red 3 of 5 Attempt 2 asks permission from a majority machines that replied 3 of 5 3 + 3 = 6 > 5 → at least 1 machine is in both groups guaranteed → that machine reports "I accepted red at 5" → the rule forces attempt 2 to propose red Machines that could have reported nothing 0 There is no message schedule, no crash pattern, and no delay that lets attempt 2 propose blue. Not "unlikely". Impossible, and it is impossible for the same reason in every run: two majorities cannot miss each other.
Two practical notes before we leave Paxos.
What we just described decides one value. Real systems need a sequence of values, an ordered log. Running the two rounds once for each position in the log is called Multi-Paxos. One change makes it fast enough to use: one node stays the proposer for many positions, so round one happens once instead of once per entry. At that point round one has become a leader election. Each entry then costs only round two: one message out, and acknowledgements back from a majority.
So Multi-Paxos with a stable leader costs exactly what Raft costs in the steady state: one round trip to a majority per decision. The differences between them are about structure and clarity, not speed.
Raft, in plain words
Raft solves the same problem and makes one big decision differently. It insists on having a leader at all times, and it restricts who is allowed to become one.
Raft has four pieces.
A term. This is a number that goes up every time an election starts, and every message carries it. Any machine that sees a higher term than its own steps down at once and adopts the new term. This is the fencing number from the replication article, and it does the same job here.
An election. Each follower waits a random amount of time, called its election timeout. If it hears nothing from a leader in that time, it increases the term and asks everyone for a vote. If a majority vote for it, it becomes the leader.
The restriction that matters. A machine only votes for a candidate whose log is at least as up to date as its own. It compares the term of the last entry first, and then the length of the log. So a voter refuses a candidate that is missing entries the voter has.
Appending. The leader takes a client request, adds it to the end of its log, and sends it to the followers. Once a majority have written it down, the entry is committed, and the leader tells everyone.
Raft gets its simplicity from that vote restriction, so look at what it replaces. Paxos lets anyone become the proposer. Then, in round one, it makes them find out what might already be decided, and it may force them to adopt someone else's value. Raft refuses to elect anyone who could be missing a decision in the first place. It moves the "find out what already happened" step from after the election into the election itself, as a condition for getting a vote.
The same one fact sits underneath. A candidate needs votes from a majority, and any committed entry is on a majority. Those two majorities share a machine. That machine's log holds the entry, so it refuses to vote for a candidate who lacks it. So a candidate missing a committed entry can never win.
The same idea, two spellings
Once you see that both algorithms rest on the same fact, comparing them stops being a contest.
| the job | Paxos does it by | Raft does it by |
|---|---|---|
| stop old attempts interfering | proposal numbers, promises to refuse lower ones | terms, and stepping down on a higher term |
| never contradict a past decision | the proposer must adopt the highest reported value | voters refuse candidates with a less complete log |
| decide one value | prepare, then accept, both to a majority | leader appends, majority writes it down |
| decide a sequence | run it per position, keep one proposer (Multi-Paxos) | one leader appends many entries in order |
| steady-state cost per decision | one round trip to a majority | one round trip to a majority |
| what it is unopinionated about | almost everything: leadership, logs, membership | nothing, which is the point |
Raft didn't add any capability. Its contribution was that it was designed to be easy to understand, and the authors measured that. They ran a study with 43 students in two classes, an advanced operating systems course at Stanford and a distributed computing course at Berkeley. The students learned both algorithms from recorded lectures and then took a quiz on each. The mean Raft score was 25.7 out of 60, and the mean Paxos score was 20.8. 33 of the 43 did better on Raft.
The second finding in that study is more useful. The authors built a statistical model that separated out how much Paxos each student already knew. It predicted a gap of 12.5 points in Raft's favour. The measured gap was only 4.9, because many of the students had met Paxos before, and that helped them a lot on the Paxos quiz. So even the paper arguing that Paxos is hard to learn found that people who had already learned it did fine.
What a decision costs
Consensus has one cost you can't remove: you can't say yes until a majority has written the thing durably to disk. That means one round trip, plus an fsync, the call that forces a write onto the disk. Where your machines sit decides the number.
Cost = network round trip to the majority + durable write Three machines in one rack round trip 0.3 ms fsync, NVMe, group committed 0.3 ms → per decision ~0.6 ms Three machines across zones in one region round trip ~1.5 ms fsync 0.3 ms → per decision ~1.8 ms Five machines across three regions, nearest 2 answer round trip to the nearest other region ~25 ms fsync 0.3 ms → per decision ~25.3 ms Now the part people get wrong. Decisions that do NOT depend on each other can be batched into one round trip: cross-zone, batches of 100 ~55,000/s cross-zone, each waits for the last ~550/s cross-region, each waits for the last ~40/s Latency is set by geography. Throughput is set by batching. A workload where every operation reads the result of the previous one cannot batch, so it is stuck at the latency number, and 40 operations per second is a real answer that has ended real projects.
Reads are the part nobody covers
Ask most engineers how to do a linearizable read from a Raft cluster, and they'll say "read from the leader." That's wrong, and the reason is worth following step by step.
The leader might not be the leader any more. A network partition can cut it off from the others, the others can elect a new leader without it, and the new leader can commit new entries. The old leader has now been deposed, replaced without being told. It hasn't noticed, because it would only notice by hearing from somebody, and it's hearing from nobody. If it answers a read from its local state, it returns a stale value with total confidence.
So a leader needs to prove that it's still the leader at the moment of this read. There are exactly three ways, and Raft's own paper and dissertation describe all three.
Go through the log. The leader puts the read into the log as an entry and commits it like a write. This is clearly correct. It costs a full round trip plus a disk write, for a read.
ReadIndex, which is a quorum check. Before answering, the leader exchanges heartbeats with a majority. If a majority still treat it as the leader, no newer leader can exist. A newer leader would have needed a majority too, and the two majorities would share a machine. This costs a round trip but no disk write. There's a second, less obvious requirement. A new leader must commit a blank no-op entry at the start of its term. Only then does it know which entries from earlier terms are committed, so it must not answer anything before that.
A lease, which is a clock check. If the leader heard from a majority at time T, it assumes it stays the leader until T plus the lease length. Until then it answers reads from local state, with no messages at all. This is the fastest by far. It's correct only if clock drift is bounded, and clock drift is how far one machine's clock runs fast or slow against another's. etcd's documentation says this plainly. Clock drift can affect lease-based reads, and if the drift is unbounded, the leader may hold the lease longer than it should. In that case this mode isn't safe.
The result that proves the thesis
In 2016, Heidi Howard, Dahlia Malkhi and Alexander Spiegelman published a paper called Flexible Paxos. It's the clearest evidence that the real requirement is intersection, meaning that quorums overlap, and not that they are majorities.
Standard Paxos uses a majority in both rounds. The paper shows that this is more cautious than it needs to be. Two round-two quorums don't need to overlap each other, and neither do two round-one quorums. Every round-one quorum only has to overlap every round-two quorum. So the real rule is:
size of the round-one quorum + size of the round-two quorum > number of machines
Majorities meet that rule, since any two majorities add up to more than the whole. But many other combinations meet it too, and some of them are better.
The only requirement: |Q1| + |Q2| > N
N = 5, so any pair summing to 6 or more works.
Q1 (election) Q2 (each write) what you get
─────────────────────────────────────────────────────
3 3 standard Paxos
4 2 writes ack from 2,
elections need 4
5 1 fastest writes,
elections need all 5
And on an even cluster, where majorities waste a node:
N = 4, majority would be 3 and 3
3 2 writes ack from 2
instead of 3
Smaller write quorums mean lower write latency and less
work per decision, paid for with rarer, more fragile
elections. Since elections happen far less often than
writes, that is frequently the trade you want, and nothing
in Paxos ever required you to make it the other way.The method
1. List the facts where two answers would be a disaster. Leadership, membership, the shard map, locks, config versions. This list should be short. Nothing outside it needs consensus, so nothing outside it should pay for it.
2. Count how often those decisions happen, and whether each one waits for the last. This is the step that kills designs, and it takes ten seconds. Independent decisions can be batched, so they go fast. In a chain where each operation reads the previous result, nothing can be batched, so each operation costs a full round trip.
3. Place the machines, then count the round trip to a majority. Same rack, same region, or across regions. The number differs by a factor of about forty, and geography sets it, not software.
4. Pick an odd group size, and ask whether one group is enough. Three or five. If you need more throughput than one group gives, you need many groups. That's a partitioning decision rather than a consensus one.
5. Say how a linearizable read is served. Through the log, a quorum check, or a lease with a stated clock assumption. If reads are allowed to be stale, say that instead, out loud, and say how stale.
6. Name the fencing number and where it's checked. This is the same requirement as in the replication article: the term, or the Paxos proposal number, often called a ballot, and the resource that compares it.
Worked examples, start to finish
Here are four systems. In each one, the obvious approach fails for a different reason: disagreement during a partition, overlap without order, the ceiling of a single group, and a leader that doesn't know it has been deposed.
A cluster's shard map, where consensus is the right tool
A sharded database needs a map from each logical shard to the physical host that holds it. Every client reads the map constantly. It changes rarely, when an operator moves a shard.
The obvious approach is to put the map in a table in the main database, which is already replicated. That works until a network partition. Then the operations tooling on each side of the partition can promote a host and write a different map. Two clients now hold different maps, and they write the same key to two different machines. The partitioning article explains why that's a data corruption bug rather than a routing bug.
This is the ideal workload for consensus, for three reasons. Two different maps would be a disaster. The map changes a handful of times a week. And the data is tiny. So you pay the cost of consensus, one round trip per change, a handful of times a week, and it buys the guarantee that there's exactly one map. Put the map in etcd or ZooKeeper and give it a version number. Clients refuse to run on a version they know is stale.
A lock for a job, where the obvious quorum is not enough
Exactly one worker may run a job. You already run a quorum store, so the obvious approach is to write a lock row with W = 2 of three replicas and treat success as owning the lock.
The first half of this article explains why that fails. Two workers can both write the lock row. Both reach two replicas, both are told success, and both believe they hold the lock. Nothing decided anything. Last-write-wins will pick one eventually, using clocks, long after both workers have started the job.
A quorum write to the data store you already run
It's cheap and uses infrastructure you already run, so it gets built. It gives you overlap: a later reader will see that a lock row exists. It doesn't give you agreement on who owns it. Two concurrent writes both succeed, because the data store was never asked to reject one. You can spot this in the code: there's no place where the data store can say no.
A compare-and-set against a consensus group
Use something that runs consensus, and use an operation that can fail. Either create the key only if it doesn't exist, or set it only if the version matches. Now exactly one of two racing workers gets an error, and that error is the point. The data store is running the competition that a quorum write never ran.
Here's what it costs. Each acquisition and each renewal costs one round trip to a majority. You take on a new system to operate. And that round trip puts a hard ceiling on how often the lock can change hands. For most job schedulers that ceiling doesn't matter, but check it rather than assume it.
Make the second worker harmless instead of impossible
The premise to attack is that you needed mutual exclusion. Usually you didn't. You needed the job's effect to happen once. Those are different requirements, and they cost very different amounts.
So keep the lease, and add the two things that let a lease survive being wrong. First, carry the lease's generation number into every write the job makes, and have the storage reject any number below the highest it has seen. Second, make the job's operations idempotent, keyed by the job's identity. Idempotent means that running an operation twice has the same effect as running it once, so a duplicate run changes nothing.
Size it. With fencing, which is that number check, a second worker starting costs a rejected write and a log line. Without it, a second worker starting causes a duplicated side effect, and somebody finds it in a reconciliation report the next week. The failure moves from silent and expensive to loud and free.
Here's what you give up. Every downstream resource now has to check the number. That's a real cost when one of them is a third-party API that has never heard of your generation number. Where that's true, you're back to a lease plus a delay longer than any likely pause, which is what Chubby's lock delay is for. Say which resources can check the number and which can't, because that list is the design.
A 100 TB store, where one group is not enough
Now the opposite case. You want a strongly consistent distributed store that holds 100 TB. Consensus gives you the ordering you need, so the obvious approach is to run one Raft group across your machines and put everything in it.
That can't work. One Raft group has one leader, and one leader means one machine appending to one log on one disk, plus a round trip per decision. TiKV's own documentation states the problem directly: its goal is to support 100 TB and more, and that is impossible for one Raft group.
The answer is many groups. Split the key space into ranges, and give each range its own small consensus group, usually of three or five replicas. CockroachDB does the same with its ranges, and describes each node taking part in hundreds of thousands of consensus groups.
That fix brings a new cost of its own.
100 TB in ranges of ~96 MB 100 TB / 96 MB ≈ 1.09M ranges → each its own Raft group, RF 3 Heartbeats, naively, at 2 per second per follower 1.09M groups x 2 followers x 2/s ≈ 4.4M messages/s → on a 100 node cluster, before any real work happens Coalesced into one message per node pair, per tick 100 x 99 ordered pairs x 2/s ≈ 19,800 messages/s ──────────────────────────────────────────────────────── reduction ~220x The consensus algorithm did not change. The transport did. CockroachDB coalesces heartbeats for exactly this reason, which is the kind of problem you only meet after the algorithm is already correct.
One Raft group holding everything
It's correct, and that's the trap: it passes every test you write. The ceiling is one leader's append rate and one round trip. So throughput doesn't improve when you add machines. It gets slightly worse. If you add a sixth and seventh replica to a group, writes get slower and the group survives more failures, but capacity doesn't change at all.
Many small groups, one per range
Partition the key space, and give each range its own group of three or five nodes. Throughput now grows with the number of groups instead of being fixed. Each group's leader can sit on a different machine, so the write load spreads out. Most strongly consistent distributed stores work this way.
Here's the cost you now carry. Background traffic grows with the number of groups, so it has to be coalesced, which means combined into fewer messages. And a transaction that touches two ranges now spans two consensus groups, so it needs a distributed commit protocol, such as two-phase commit, on top. You've traded a throughput ceiling for a coordination problem.
Ask which of the data needs consensus at all
The premise to attack is that everything in the store needs the same ordering guarantee. Usually very little of it does.
Consensus is for facts where two answers would be a disaster. In most products that's a small fraction of the bytes: account balances, inventory counts, permissions, idempotency keys. The rest is nearly all of the volume: user content, events, logs, derived views, and blobs such as images and video. That data wants ordinary replication with a stated staleness, which costs about a tenth as much and is simpler to run.
Size it. If 3 percent of your write volume needs consensus ordering and you put 100 percent of it through Raft, you pay a majority round trip about thirty times more often than the requirement needs.
Here's what you give up. You run two storage systems instead of one, and every future engineer has to learn where the boundary between them sits. That boundary will also move, so draw it on a product concept rather than a technical one. If you can't draw it clearly, one strongly consistent store is the honest choice, and you plan around its throughput ceiling.
A read that must not be stale
The last example is a read. A payments service checks a balance before it allows a withdrawal, so the read must not be stale. The system uses Raft, and the code reads from the leader.
We've covered why that isn't enough: the leader may have been deposed without knowing it. So the fix is one of the three mechanisms, and here the choice is open.
Read from the leader's local state
Almost every first implementation does this, because "the leader has the newest data" is nearly true, and it makes reads free. The failure needs a partition, so it's rare and doesn't show up in testing. And it returns a believable number rather than an error. A stale balance that allows a double withdrawal is the kind of bug a customer finds.
ReadIndex, a quorum check before answering
Before answering, the leader confirms with a majority that it's still the leader. If a majority agrees, no newer leader can exist, by the intersection argument. This costs a round trip and no disk write. etcd ships it as the default, under the name ReadOnlySafe.
The cost lands on every read: a round trip to a majority. For a service with many reads, that's a large bill, and it's why people reach for the next option.
Decide per read, and stop paying for reads that do not need it
The premise to attack is that a service has one read consistency. It doesn't, and the requirement varies a lot inside one product. The balance check before a withdrawal needs a linearizable read. The balance shown on the dashboard doesn't. If it's 2 seconds stale, nobody can tell.
So sort the read paths into classes, and price each class separately. Withdrawal checks pay the quorum round trip. Dashboards read a follower and show a timestamp. Reports read an asynchronous copy. The lease option sits in the middle. Use it only where you can state a bound on clock drift, and where you have monitoring that would notice if the bound were broken. That bar is higher than it sounds, and it's why etcd documents the mode as unsafe under unbounded drift.
Size it. If 1 read in 200 needs to be linearizable, then sending every read through a quorum costs 200 times more coordination than the requirement.
Here's what you give up: one simple rule about what a read means. A written classification replaces it, and somebody has to maintain it. If nobody will, a quorum read on everything is a defensible choice. It trades money for not having to think.
Where it goes wrong
Ordered by how often each one shows up.
1. Believing W + R > N is consensus
The toolkit above covers this in full. Overlap guarantees that a read sees a completed write. It says nothing about which of two concurrent writes came second. A data store that settles that with last-write-wins throws data away on purpose, using clocks it doesn't control.
The test question is: what happens when two clients write the same key in the same millisecond? Consensus has an answer. Quorums don't.
2. Reading from the leader and calling it linearizable
We covered this above too, and it ranks high here because the code looks obviously right. The leader is the leader, so its data must be current. But leadership is a fact about the whole cluster, and the leader is the one component that can't check it on its own.
3. Putting the data path through consensus
Consensus costs a majority round trip per decision. If that sits on your busy write path at high volume, you've bought ordering you mostly didn't need. The price shows up as a throughput ceiling that no tuning removes. The fix is a boundary: a small set of facts behind consensus, and the volume somewhere else.
4. Missing that dependent operations cannot batch
This is the least obvious performance mistake in the area. A consensus group's headline throughput comes from batching many independent entries into one round trip. If each of your operations reads the result of the one before, batching doesn't apply. Your ceiling is one round trip per operation, which across regions is a few dozen a second. Load tests written with independent keys won't find this, because independent keys are exactly the case that batches well.
5. Even-sized groups
Four voters survive the same single failure as three, and they give you one more machine that can fail. The replication article has the arithmetic, including why two is worse than one. Use three, five or seven.
6. Changing membership in one step
This one gets its own arithmetic. A mistake here causes split brain, where two leaders each believe they're in charge at the same time, and the team causes it themselves.
Growing from 3 machines to 5 in a single step.
Old group {A,B,C} majority = 2
New group {A,B,C,D,E} majority = 3
Machines adopt the new config at different moments, so
during the change both configs are live. Now:
{A,B} is a majority of the OLD group
{C,D,E} is a majority of the NEW group
shared members 0
→ two disjoint majorities
→ two leaders, both legitimate, same moment
→ the one fact this article rests on is broken
Growing from 3 to 4 instead
old majority 2, new majority 3, and any 3 of
{A,B,C,D} must include at least one of {A,B}
→ old and new majorities always share a member safe
In general, N to N+1 is always safe because
majority(N) + majority(N+1) > N+1.
N to N+2 is not safe when N is odd, as with 3 or 5.That's why Raft offers two safe ways to change membership. The first is joint consensus: during the change, a decision needs a majority of the old group and a majority of the new one. The second is simpler: only ever add or remove one machine at a time. Both work by making two separate majorities impossible. You need one of them.
7. Assuming the paper is the implementation
Google wrote a paper about this. "Paxos Made Live," from 2007, describes building the Paxos implementation underneath Chubby, Google's lock service. Its central message is that there are significant gaps between the description of the algorithm and the needs of a real system. The authors sort their difficulties into three groups: algorithmic gaps in the published literature, software engineering problems, and failures they didn't expect. They concluded that a working implementation took a lot more than translating the pseudocode.
That team was building one of Google's core services, and it still found the paper was not enough. So use etcd, ZooKeeper, or a well-tested Raft library. Writing your own is a research project, not a ticket.
8. Expecting a guarantee that provably does not exist
In 1985, Fischer, Lynch and Paterson proved that no deterministic algorithm can guarantee consensus in a fully asynchronous system if even one process may crash. A fully asynchronous system is one with no upper limit on how long a message or a step can take. The result is not that consensus is hard there. It's impossible. The reason is the one from the replication article: a crashed process and a very slow one look exactly the same from outside, so unlucky timing can always keep an algorithm from deciding.
Every algorithm here lives with that result rather than solving it, so be precise about what they give up. They keep safety always, and give up guaranteed liveness. Safety means never deciding two different values. Liveness means eventually deciding something. Raft and Paxos never decide two different values, whatever the timing. In principle, they can go for an unbounded stretch without deciding anything. The random election timeout is exactly this trade: it makes a stalemate less and less likely with each round, but never impossible.
So if someone asks whether your system can stall, the answer is yes, in theory, and that's not a bug in your design. A design that gave up safety to avoid stalling would have the bug.
If you memorise nothing else
| fact | why it matters |
|---|---|
| Any two majorities share at least one member | the single fact under every algorithm here |
W + R > N gives overlap, not agreement | two concurrent writes both succeed, order is lost |
| A quorum store is never asked to reject a write | consensus is the thing that runs a competition |
| Paxos: a proposer must adopt the highest value it hears | this one rule is the whole safety argument |
| Raft: a voter refuses a candidate with a less complete log | the same argument, moved into the election |
| Multi-Paxos with a stable leader costs what Raft costs | one round trip to a majority per decision |
| Raft's contribution was understandability, and it was measured | 33 of 43 students scored better on Raft |
| Latency comes from geography, throughput from batching | ~40 decisions/s across regions if each waits |
| Dependent operations cannot batch | load tests with independent keys will not find this |
| Reading from the leader is not linearizable | it cannot know alone that it is still the leader |
| Three read options: the log, a quorum check, a lease | a round trip, a round trip, or a clock assumption |
| A new leader commits a blank no-op first | so it knows what earlier terms actually committed |
| Flexible Paxos: the two quorum sizes need only sum to more than N | majorities are one point on that line, not the line itself |
| Adding two machines at once can create two leaders | one at a time, or joint consensus. Not optional |
| Consensus keeps safety and gives up guaranteed liveness | FLP 1985, and no design choice avoids it |
| Google found the paper was not the implementation | use etcd or a real library, not the pseudocode |
What is expected at each level
Mid-level
Know what a quorum is and why a majority works: any two majorities share a member. Know that consensus means several machines agreeing on one value and never taking it back. Be able to say roughly what Raft does, in terms of a leader, a term, and a log that a majority must write down.
You aren't expected to reproduce Paxos's two rounds unprompted, or to raise linearizable reads or flexible quorums. You are expected to know that consensus costs a round trip to a majority, and to reach for etcd or ZooKeeper rather than writing your own.
The mistake to avoid is saying that quorum reads and writes make a system consistent. If you take one thing into an interview, take the difference between overlap and agreement.
Senior
You drive this part of the discussion, and three things must come up without prompting.
A short list of what goes behind consensus, with everything else outside it. Leadership, membership, the shard map, locks. Then say that the data path doesn't go through it. Reaching for Raft for the whole workload is the most common senior-level mistake here, and it shows up as a throughput ceiling.
The cost per decision, with the deployment shape attached. One round trip to a majority: under a millisecond in a rack, and 25 milliseconds across regions. Then say whether your operations depend on each other, because that decides whether batching saves you.
How a linearizable read is served. Name one of the three mechanisms, or say clearly that your reads may be stale, and by how much. "We read from the leader" isn't an answer, and a good interviewer will push on it.
Disqualifying: treating W + R > N as consensus, and proposing an even-sized group.
Staff+
The question shifts from how to use consensus to how little of the system should touch it.
Draw the boundary on a product concept. Say which facts would be a disaster in duplicate, and what fraction of the write volume they are. If it's 3 percent, say so, because that number is the argument for having a boundary at all. Then say who maintains the boundary as the product changes, because a boundary nobody writes down drifts.
Price the ceiling before proposing the architecture. Decisions per second, how they depend on each other, and the round trip. A design with a serial chain of operations across regions has a ceiling near 40 operations a second. Finding that in a design review is worth more than any diagram.
Choose read consistency per path. Most reads don't need to be linearizable. Paying a majority round trip on all of them is a large recurring bill for a requirement that applies to a fraction. Say which paths pay, and what the others show instead.
Treat membership change as the risky operation it is. One machine at a time, or joint consensus. Be able to explain in two lines why adding two at a time can produce two leaders. Teams get this wrong during capacity growth, which means while under load.
Say what you would not build. Each of these can cost a team a quarter.
Your own Paxos or Raft implementation, when Google published a paper about how hard that is and etcd exists. A single large consensus group for the whole dataset, which is correct, passes all tests, and can't scale. And lease-based reads without a monitored bound on clock drift, which is a correctness assumption presented as a performance optimisation.
A distributed lock service for a problem that idempotency and a fencing token would have solved for free. Synchronous consensus across regions on the busy path, where the round trip sets a ceiling no tuning moves. And a home-made membership-change procedure. It's the one operation where a mistake produces two leaders rather than an error.
Sources
Every number attributed to a paper, project or study below comes from that published source. The quorum, cost and membership arithmetic is worked in the article with its inputs stated.
- In Search of an Understandable Consensus Algorithm, Diego Ongaro and John Ousterhout, USENIX ATC 2014, and the extended version and user study material. Terms, the election restriction requiring a candidate's log to be at least as up to date, and the Leader Completeness property. Also the 43-student study across Berkeley and Stanford, with mean scores of 25.7 for Raft against 20.8 for Paxos out of 60. And the note that prior Paxos exposure narrowed the measured gap from a predicted 12.5 points to 4.9.
- Raft's dissertation material on client interaction, for the two extra precautions a linearizable read needs without going through the log. A leader must commit a blank no-op entry at the start of its term, so it knows what earlier terms committed. It must also exchange heartbeats with a majority before answering a read-only request. The same material describes the lease-based alternative and its dependence on bounded clock drift.
- Flexible Paxos: Quorum Intersection Revisited, Heidi Howard, Dahlia Malkhi and Alexander Spiegelman, OPODIS 2016. That intersection is required only across the two phases rather than within them. That majority quorums are one way among many to satisfy it, and the concrete gains including shrinking the second-phase quorum on an even-sized cluster.
- Paxos Made Live, An Engineering Perspective, Tushar Chandra, Robert Griesemer and Joshua Redstone, PODC 2007. The significant gaps between the published algorithm and a working system, sorted into algorithmic gaps in the literature, software engineering challenges, and unexpected failures.
- Impossibility of Distributed Consensus with One Faulty Process, Michael Fischer, Nancy Lynch and Michael Paterson, JACM 1985. That no deterministic algorithm guarantees consensus in a fully asynchronous system with a single crash fault, and that the reason is the indistinguishability of a crashed process from a slow one.
- etcd raft package documentation. The ReadOnlySafe mode, which confirms leadership with a quorum and is the default, against ReadOnlyLeaseBased, which relies on the leader lease and is documented as unsafe when clock drift is unbounded.
- Multi-raft, TiKV. That supporting 100 TB and more is impossible for a single Raft group, and the design of one group per region of the key space.
- Scaling Raft, Cockroach Labs. Nodes participating in very large numbers of consensus groups, the heartbeat traffic that follows from it, and coalescing heartbeats per node pair to control it.