Paxos is an algorithm for Consensus. The goal is to maintain a replicated, consistent append-only log; in practice, this log can record the sequence of operations, allowing all nodes to have the same processing order.
The Paxos algorithm guarantees safetyโonly a single proposed value can be chosenโbut not livenessโsome proposed value is eventually chosen, and all nodes learn of it. The method operates with a lossy, asynchronous network on nodes that can crash.
Paxos organizes nodes into three roles: proposers, acceptors, and learners. Proposers propose a new entry to append, and acceptors accept these proposals; if a proposal is accepted by a majority, itโs decided as the final value and send to the learners. We can organize this procedure into two phases: prepare and accept.
Prepare
In the first phase, suppose node
Then, if node
- If it already acknowledge a
with , then do nothing. - If it previously accepted proposals for this entry, respond with
where is the highest proposal number it has accepted, and is the corresponding value. - Otherwise, respond with
Here,
Accept
In the second phase, if
When
- If
already acknowledged with , then do nothing. - Otherwise,
accepts the proposal and sends to all learners.
When a learner