System design paper · 2014

Raft

Ongaro and Ousterhout · USENIX ATC 2014

How Raft keeps a group of servers agreeing on one ordered list of commands, with one leader, simple votes and rules a team can follow.

The leader copies its list of changes to the other servers. An entry is safe once a majority holds it: here 3 of 5 servers hold entry 5.

You’ll learn to

  • Explain how Raft elects one leader at a time and why random timeouts stop elections from stalling.
  • Trace how a leader copies its list of commands to the others, repairs lists that differ and decides an entry is safe.
  • Explain why a new leader always holds every entry that was already confirmed to a client.
  • Name what production systems added to Raft, and the failure that showed why.

The idea in short

Many systems need a small group of servers, often three or five, to agree on the same data even when some of them crash. The classic way to do this, an algorithm called Paxos, is famously hard to understand, so it is hard to build correctly. Raft was designed to do the same job in a way engineers can follow.

One server is the leader. It takes every change, writes it to the end of a numbered list and copies the list to the others. A change is safe once more than half the servers have stored it. If the leader goes quiet, the others hold a vote, and a server can only win if its list already contains every safe change.

The problem

Some data is too important to keep on one server. Which server is the primary database right now, which machines belong to the cluster, who holds a lock: if the one server that knows the answer crashes, everything that depends on it stops. So systems keep this data on a small group of servers, usually three or five, and make them agree.

Getting a group to agree is called : every server ends up with the same answer, even when some of them crash or messages arrive late. The usual way to use it is a . Each server keeps a list of commands, such as “set x to 3”, and applies them one by one, in order. If every server applies the same commands in the same order, every server ends up with the same data. Consensus is the part that keeps the lists identical.

When the paper was written, the standard answer was , an algorithm Leslie Lamport published in 1998. It is correct, and it had been proven. It also had two problems, Diego Ongaro and John Ousterhout argued.

The first was that almost nobody understood it. At NSDI 2012, a large systems conference, they asked attendees informally and found few who were comfortable with Paxos, even among experienced researchers. The authors themselves needed almost a year, several simplified explanations and an attempt at their own design before they understood the whole protocol.

The second was that Paxos, as published, gets servers to agree on a single value, such as one command. Real systems need a long sequence of values, one per command, and the extension that does this was never fully written down. So every team built its own version, and those versions drifted from the proofs. The team behind Chubby, Google’s lock service, put it this way: there are “significant gaps between the description of the Paxos algorithm and the needs of a real-world system”.

So the question the paper answers is: can consensus be designed so that engineers understand it well enough to build it correctly, without giving up safety or speed?

The design choices

Most algorithms are designed to be correct, fast or short. ’s main goal was to be understandable. Whenever the authors had two ways to do something, they asked which one a reader could explain more easily, and picked that.

Our biggest sale ever · Black Friday

Flat 50% Off

Pro

Continue reading

Unlock every course, now and later

  • System Design, live
  • AI Engineering, live
  • Data Engineering, live
  • Machine Learning Engineering, live
  • Inference Engineering, coming soon
  • AI Research, coming soon
  • Performance Engineering, coming soon
  • Agent & Harness Engineering, coming soon
  • LLM Fine-tuning, coming soon
  • LLM Pre-training & Post-training, coming soon
  • Reinforcement Learning, coming soon
  • AI Infrastructure & Platform Engineering, coming soon
  • AI Evaluation & Safety, coming soon
  • Forward Deployed Engineering, coming soon
  • Cloud Computing, coming soon
  • DevOps, coming soon

50% off · Annual and Lifetime

BLACKFRIDAY50Applied at checkout

Choose a plan

About the paper

In Search of an Understandable Consensus Algorithm by Ongaro and Ousterhout, USENIX ATC 2014.

Read the original paper

More System design papers

All papers