CS PAPERS DEEP-READ · PAPER 44

Paxos Made Simple

Leslie Lamport · Microsoft Research · ACM SIGACT News · 2001

中文 →

What did this paper do?

In 2001, Leslie Lamport re-told, in plain English, the Paxos algorithm he had invented — a way for a group of machines scattered across a network they can't trust to reach a single, never-reversed agreement on some one thing. Almost every large online service you use has it hiding underneath: how a database picks its primary node, whether a piece of data really got written, who's in charge of a cluster — these "every machine must agree on the same answer" problems are solved by consensus algorithms like Paxos.

First, the hard part

Picture a group of friends trying, by phone, to settle on one restaurant — but calls drop at random, people suddenly fall asleep and wake up a while later (machines crashing and rebooting), and messages arrive late or twice. The requirement is brutal: everyone must end up at the same place, and once it's settled, no one may ever believe it was somewhere else. The difficulty: there's no "center everyone trusts," the messages are unreliable — so how do you rule out "half the group thinks it's A, half thinks it's B"? (One assumption: nobody lies here; machines only crash, they don't deliberately send false messages — lying is a different, harder problem.)

The idea

Paxos's answer is two rounds of talking + a queue ticket. Anyone who wants to propose first draws an ever-larger ticket number (a later ticket is always bigger than an earlier one). In the first round they take that ticket to a majority of people and ask, "will you promise to me?"; only in the second round do they formally push their chosen restaurant and ask that majority to "accept" it. A restaurant accepted by a majority counts as "settled."

How does it keep two answers from clashing?

Two rules hold everything together. First: everyone honors only the bigger ticket — once you've promised to ticket 5, you ignore anyone with a smaller number. Second, and the clever one: before a proposer pushes their own restaurant in round two, they must ask around first; if anyone says "I've already accepted some place," the proposer must switch to championing that place and drop their own.

Add the magic of "majority": any two groups that each form a majority must share at least one person. So once a restaurant has been settled, anyone asking around later is guaranteed to run into that "overlapping person," hear from them that it's already settled, and dutifully carry it forward. The decision is therefore forever unique and never overturned.

What it gave us

This "ask around first, then push, honor the bigger ticket, reuse the old value" discipline became the bedrock of nearly every strongly-consistent distributed system: Google's Chubby lock service, the Spanner global database, and the primary-election logic in all sorts of databases are Paxos at heart. The later, easier-to-follow Raft is a repackaging of the same ideas.

Remember one thing

To make a set of unreliable machines agree on one thing: draw an ever-increasing ticket, ask a majority around first, honor whoever's ticket is bigger — and before pushing your own value, reuse any value others have already accepted. Because "any two majorities must overlap," a value once settled can never be overturned. Honest caveat: it's famously hard to understand, it survives crashes but not lies, and plain Paxos can stall when two proposers keep grabbing bigger tickets from each other (fixed by electing a single "leader").

Want the two-phase flow diagram, why majorities must overlap, and how it becomes a real system? → switch to the deep read