Distributed Systems Consensus
Paxos and Fault-Tolerant Distributed Consensus
1. The Consensus Problem
A distributed system consists of multiple independent processes, such as computers, virtual machines, or software agents, that communicate over a network. These processes may need to agree on the result of a decision even though they operate independently and may experience failures.
For example:
Several servers may need to agree on the balance of a bank account.
Multiple database replicas may need to agree on the next transaction to execute.
Servers in an online game may need to agree on which player obtained a unique item.
Cloud services may need to agree on shared configuration settings.
Without agreement, different parts of the system could maintain incompatible realities. One server might record that a player owns a sword while another records that the player owns a shield. One database replica might process a deposit before a withdrawal, while another processes them in the opposite order.
Consensus is the process by which a group of distributed processes chooses one value from among multiple proposed values and treats that value as the authoritative result for a particular decision.
A consensus algorithm must ensure that:
Competing proposals are resolved.
Only one value is selected for each decision.
All processes eventually learn the selected value.
The system continues operating despite failures, delays, and lost messages whenever progress is possible.
Consensus is difficult because the system cannot reliably distinguish between several possibilities:
A process may be slow or may have crashed.
A message may be delayed or may have been lost.
A process may have restarted and forgotten information held only in memory.
Two proposers may act at nearly the same time with conflicting values.
Paxos provides a method for achieving fault-tolerant agreement in this uncertain environment.
2. Safety and Liveness
A consensus algorithm has two broad categories of requirements: safety and liveness.
Safety
Safety means that the system never produces an incorrect or contradictory result. Safety must hold regardless of message delays, process crashes, or other non-malicious failures.
Paxos specifies three central safety requirements.
2.1 Only Proposed Values May Be Chosen
A value cannot appear from nowhere. If a value is chosen, some proposer must have originally proposed it.
This prevents:
Accidental selection of invalid data.
Phantom values generated by system errors.
Decisions that were never requested by any participant.
2.2 At Most One Value Is Chosen
For a given consensus instance, only one value may ever be chosen.
If value X is chosen, the system must never later choose value Y for that same decision, where X=Y.
This prevents inconsistent states such as:
Two different balances for one account.
Two servers assigning the same unique item to different players.
Replicas executing different commands in the same sequence position.
Once chosen, the value is effectively immutable for that consensus instance.
2.3 A Process Learns a Value Only If It Was Chosen
A process must not believe that a value was chosen unless that value actually satisfied the conditions for being chosen.
This avoids false confirmations. For example, a server must not finalize a transaction merely because it received an incomplete or misleading set of messages.
Safety means “nothing bad ever happens”: no unproposed value is chosen, two different values are never chosen for one instance, and no process learns a false decision.
Liveness
Liveness means that the system eventually makes progress rather than remaining stuck forever.
Paxos aims for two liveness properties:
Some value is eventually chosen.
Once a value is chosen, processes eventually learn that value.
Safety and liveness can conflict. A system could remain perfectly safe simply by refusing to make any decisions, but such a system would be useless. Conversely, a system that always makes decisions but sometimes chooses conflicting values would be unsafe.
3. Why a Single Decision-Maker Fails
The simplest possible design uses one central acceptor:
Proposers send values to the acceptor.
The acceptor selects one valid value.
The acceptor announces the decision.
This design is simple and efficient when nothing fails. However, the central acceptor is a single point of failure.
If that acceptor:
Crashes,
Loses network connectivity,
Becomes overloaded, or
Permanently stops operating,
then no further decisions can be made. The rest of the system may still be functioning, but it cannot progress because the only decision-maker is unavailable.
A distributed system uses multiple acceptors to avoid depending on one component. However, using multiple acceptors creates a new challenge: the acceptors must coordinate so that they do not accept conflicting values.
4. The Paxos System Model
Paxos operates in an asynchronous, non-Byzantine model.
4.1 Asynchronous Operation
An asynchronous system does not assume reliable timing.
Processes may:
Run at arbitrary speeds.
Pause for unpredictable periods.
Crash and later restart.
Take an arbitrarily long time to respond.
Network messages may:
Be delayed for an arbitrary length of time.
Be duplicated.
Be lost entirely.
Arrive in an order different from the order in which they were sent.
There is no guaranteed upper limit on how long a message will take to arrive. Therefore, a process cannot always determine whether another process is merely slow or has crashed.
4.2 Crash and Restart Failures
Paxos assumes that processes can fail by stopping rather than by acting maliciously. A process may later restart, but it may not remember information that existed only in volatile memory.
This creates a requirement for stable storage.
Any information necessary to preserve consensus safety must survive a process crash and restart.
Important information stored durably by acceptors includes:
The highest proposal number to which the acceptor has promised.
The highest-numbered proposal the acceptor has accepted.
The value associated with that accepted proposal.
Writing this information only to RAM is unsafe because RAM contents may disappear after a crash.
In practice, stable storage can involve:
Disk storage.
Write-ahead logging.
Journaling.
Nonvolatile memory.
Durable solid-state storage such as NVMe devices.
The specific technology can change, but the principle remains the same: promises and accepted proposals must be recoverable.
4.3 Non-Byzantine Behavior
Paxos assumes non-Byzantine failures.
Processes may be:
Slow,
Disconnected,
Crashed, or
Restarted.
However, they do not intentionally lie or send arbitrary malicious messages. Messages may be lost or duplicated, but a message that arrives is not corrupted into a different message.
This differs from the Byzantine model, in which processes may behave maliciously, lie, or deliberately sabotage agreement. Byzantine fault-tolerant algorithms, such as PBFT, are designed for that more difficult setting. Paxos addresses crash and communication failures involving otherwise honest participants.
5. Logical Roles in Paxos
Paxos divides responsibilities into three logical roles. A single physical server may perform all three roles simultaneously.
Proposers
Proposers suggest values for the system to choose.
Examples include proposals to:
Set an account balance.
Execute a transaction.
Update a configuration.
Place a command into a particular log position.
A proposer initiates the consensus process and attempts to persuade acceptors to accept a specific proposal.
Acceptors
Acceptors are the participants that determine whether proposals are accepted. They provide the voting mechanism that protects consistency.
Acceptors:
Receive prepare requests.
Make promises about future proposals.
Report previously accepted proposals.
Accept proposals when the relevant conditions are satisfied.
Persist critical state in stable storage.
A value becomes chosen when a sufficient quorum of acceptors accepts the same proposal.
Learners
Learners discover which value was chosen.
After learning the result, learners may:
Update local state.
Execute a command.
Inform clients.
Apply a configuration change.
Replicate the decision to another component.
Learners do not necessarily participate in deciding the value; their primary responsibility is to learn and use the outcome.
6. Majority Quorums
Paxos uses multiple acceptors and defines a value as chosen when a majority of acceptors accepts the same proposal.
For a group of N acceptors, a majority requires more than half:
For example:
Three acceptors require two for a majority.
Five acceptors require three.
Seven acceptors require four.
Why a Majority Is Necessary
The crucial property is that any two majorities overlap in at least one acceptor.
Suppose there are five acceptors and a majority consists of three:
One majority might be acceptors 1, 2, and 3.
Another might be acceptors 3, 4, and 5.
Both majorities include acceptor 3.
If an acceptor is prevented from accepting conflicting values, two different proposals cannot each receive a majority. Any two majority groups would share at least one acceptor, and that shared acceptor would have to accept both conflicting proposals.
Majority intersection provides the mathematical foundation for Paxos safety.
A majority also provides fault tolerance. If a system has five acceptors, it can continue making decisions as long as at least three can communicate and operate.
7. The Problem with Accepting Only the First Proposal
An initial rule might require each acceptor to accept only the first proposal it receives. This appears safe because an acceptor would never vote for two different values.
However, it can prevent progress.
Consider five acceptors:
Proposer P sends value X to acceptors 1, 2, and 3.
Proposer Q sends value Y to acceptors 3, 4, and 5.
Acceptors 1 and 2 accept X.
Acceptors 4 and 5 accept Y.
Acceptor 3 accepts whichever proposal arrives first.
It is possible for only two acceptors to accept X and only two to accept $Y. Neither value reaches the majority of three. No value is chosen.
This creates a hung-jury situation: the system remains safe, but it fails to make progress.
Paxos therefore allows an acceptor to accept more than one proposal. The safety mechanism is not “one proposal per acceptor”; instead, it is based on proposal numbers and rules that ensure later accepted proposals preserve the already-established value.
8. Proposal Numbers and Proposal Identity
A Paxos proposal is identified by a unique, increasing proposal number and a value:
where:
N is a unique natural-number proposal identifier.
V is the proposed value.
For example, (101,X) means proposal number 101 carrying value X.
Proposal numbers allow the system to distinguish different attempts to reach consensus. An acceptor may accept multiple proposals with different numbers, but the safety rules constrain the values those proposals may carry.
A proposal is chosen when that exact proposal pair, including both its number and value, is accepted by a majority.
9. The Development of Paxos Safety Rules
Paxos derives increasingly strong rules to preserve the chosen value across later proposals.
P2: Later Chosen Proposals Preserve the Value
The first important rule is:
If a proposal with value V is chosen, then every higher-numbered proposal that is also chosen must have value V.
If proposal (101,X) is chosen, then proposal (105,Y) cannot also be chosen when Y=X. Any later chosen proposal must carry X.
P2 expresses the desired safety outcome, but it is not yet sufficient as an operational rule. An acceptor that has not learned that (101,X) was chosen might still accept a higher-numbered conflicting proposal.
P2A: Every Later Accepted Proposal Preserves the Value
P2 is strengthened to:
If a proposal with value V is chosen, then every higher-numbered proposal accepted by any acceptor must also have value V.
This rule applies even when the later proposal has not received a majority. Once X has been chosen, an acceptor must not accept a higher-numbered proposal carrying Y.
However, P2A still describes what must be true after a proposal is accepted. It does not prevent a proposer from issuing a conflicting proposal before learning that an earlier value was chosen.
P2B: Every Later Issued Proposal Preserves the Value
The strongest form is:
If a proposal with value V is chosen, then every higher-numbered proposal issued by any proposer must have value V.
If (101,X) is chosen, no proposer may issue (105,Y). Any proposal with a higher number must carry X.
P2B is the desired safety guarantee, but it cannot be implemented merely by having proposers remember every decision. A proposer may be disconnected, delayed, or restarted. Paxos therefore introduces a practical invariant that allows proposers to determine which value they are permitted to issue.
10. P2C: The Practical Invariant
P2C provides the operational condition that allows P2B to be maintained.
Before issuing proposal (N,V), a proposer must identify a majority set of acceptors, called S, such that one of the following conditions holds:
No acceptor in S has accepted any proposal numbered lower than N; or
At least one acceptor in S has accepted an earlier proposal, and V is the value of the highest-numbered proposal accepted by any acceptor in $S.
In simpler terms, the proposer must first ask a majority about its history.
Condition A: No Earlier Accepted Proposal
If none of the majority acceptors has accepted a lower-numbered proposal, then the proposer may use its own desired value.
The proposer is effectively starting with a clean majority for that proposal number.
Condition B: An Earlier Proposal Exists
If one or more acceptors report earlier accepted proposals, the proposer must use the value associated with the highest-numbered one.
For example:
A proposer intends to issue (105,?).
A majority reports that proposal (98,Z) is the highest-numbered earlier proposal they have accepted.
The proposer must issue (105,Z).
It cannot issue (105,Y), even if Y was its original preferred value.
This rule ensures that a value that may already have been chosen—or may be close to being chosen—is carried forward into later rounds rather than replaced by a conflicting value.
11. The Two Phases of Paxos
The Paxos protocol implements P2C through two phases:
Prepare phase, also called the promise phase.
Accept phase, also called the propose phase.
The phases are performed for one consensus instance at a time.
12. Phase One: Prepare
Step 1A: Choosing a Proposal Number
A proposer selects a new proposal number N.
The number must:
Be greater than any proposal number previously used by that proposer for the same consensus instance.
Be unique across proposers.
The proposer then sends a prepare request containing N to a majority of acceptors.
The request effectively asks:
Will the acceptor promise not to accept proposals numbered less than N?
Step 1B: Acceptor Processing
When an acceptor receives a prepare request for N, it compares N with the highest proposal number to which it has already promised.
If:
the acceptor:
Updates its highest promised number to N.
Writes that promise to stable storage.
Promises not to accept any proposal numbered less than N.
Sends a response to the proposer.
Reports the highest-numbered proposal it has previously accepted, if any.
The response therefore contains both:
A promise about future behavior.
Historical information about past accepted proposals.
If the acceptor has never accepted a proposal, it reports that no previous proposal exists.
Rejection of an Older Prepare Request
If:
the acceptor ignores the prepare request or rejects it.
The acceptor has already promised to honor a proposal number at least as high as maxPromised, so it cannot accept a lower or equal prepare request as a new promise.
13. Phase Two: Accept
Step 2A: Selecting the Value
The proposer waits for promise responses from a majority.
If it receives a majority, it determines which value to send:
If no response reports a previously accepted proposal, the proposer may use its own desired value.
If any response reports an accepted proposal, the proposer must use the value associated with the highest-numbered accepted proposal among all responses.
This rule directly implements P2C.
The proposer then sends an accept request containing:
to the same majority of acceptors.
Step 2B: Acceptor Processing
When an acceptor receives an accept request for (N,V), it checks whether a higher promise has been made.
The acceptor accepts the proposal if:
Equality is permitted because the promise was only to reject proposals numbered less than N.
If the condition holds, the acceptor:
Records (N,V) as its highest accepted proposal.
Writes the accepted proposal to stable storage.
Sends an accepted response to the proposer and, depending on the learning design, possibly to learners.
If another proposer has already caused the acceptor to promise a higher number, then:
and the acceptor rejects or ignores the accept request.
Choosing the Value
When a majority of acceptors accepts the same proposal (N,V), V is chosen for that consensus instance.
The proposal number identifies the specific proposal, while the value is the decision that other processes must learn and use.
14. Stable Storage and Crash Recovery
Stable storage is essential for acceptors because their promises and accepted proposals must survive failures.
An acceptor must remember:
Its highest promised proposal number.
Its highest accepted proposal number.
The value attached to that accepted proposal.
If an acceptor loses this information after a restart, it might accept an old conflicting proposal. That could undermine the majority-intersection argument and violate safety.
For example, an acceptor might:
Promise not to accept proposals below 100.
Crash before recording that promise durably.
Restart and forget the promise.
Accept an older proposal numbered 50.
This behavior could allow conflicting proposals to obtain majorities.
Proposer Storage Requirements
Proposers do not require stable storage for safety in the same way acceptors do. A proposer may abandon an attempt after a crash or failure.
When it tries again, it must use a new, higher proposal number. An abandoned proposal number can safely be discarded as long as the proposer never reuses it in a conflicting way.
15. Learning the Chosen Value
A value is not useful unless learners discover it.
Direct Notification
The simplest method is for every acceptor to notify every learner whenever it accepts a proposal.
A learner watches these messages and concludes that a proposal is chosen when it observes acceptance by a majority.
This method is direct and can provide quick notification, but it may generate many messages.
If there are A acceptors and L learners, direct communication can require approximately:
messages for one announcement.
For example, three accepting acceptors notifying 100 learners require approximately 300 messages.
Distinguished Learner
A more efficient method designates one distinguished learner.
Acceptors send accepted messages to the distinguished learner.
The distinguished learner detects when a majority has accepted a proposal.
It informs the remaining learners that the value was chosen.
With three relevant acceptors and 100 learners, this may require approximately:
messages rather than 300.
The communication cost is closer to the sum of the number of acceptors and learners than to their product.
Trade-Offs
A single distinguished learner introduces a new weakness:
It may become a bottleneck.
If it crashes, other learners may not learn the decision promptly.
It becomes a potential single point of failure for information dissemination.
A common compromise is to use several distinguished learners. Acceptors send information to all of them, and the distinguished learners coordinate or notify the remaining learners. This improves reliability while avoiding the full message cost of direct all-to-all notification.
Recovering Missing Information
A learner may fail to hear about a decision even though a value was chosen.
It can attempt to recover the information by:
Asking acceptors what they have accepted.
Contacting other learners.
Initiating a new Paxos round for the same consensus instance.
If the learner starts a new round with a sufficiently high proposal number:
If a value had already been chosen, the phase-one responses force the new proposer to adopt that value.
If no value had been chosen, the new round can cause a value to be chosen.
Thus, a new round can both discover an existing decision and force progress when no decision has yet been made.
16. Livelock and the Limits of Asynchrony
Paxos is designed to preserve safety, but basic Paxos may fail to make progress when proposers continually interfere with one another.
Deadlock Versus Livelock
Deadlock occurs when processes stop making any activity because each is waiting indefinitely for another.
Livelock occurs when processes remain active but make no useful progress. They continue sending messages, processing requests, and consuming resources, yet no value is chosen.
Example of Paxos Livelock
Suppose proposer P begins with proposal number 100:
P completes phase one and receives promises from a majority.
Before P sends its phase-two accept request, proposer Q sends a prepare request for proposal number 101.
The same majority promises to Q not to accept proposals below 101.
P's accept request for 100 is now rejected.
P retries with proposal number 102.
Before P completes phase two, Q or another proposer issues proposal number 103.
The new higher promise prevents proposal 102 from being accepted.
This pattern can continue:
Each proposer completes phase one but is preempted before completing phase two. No proposal obtains a majority, so no value is chosen.
The FLP Impossibility Result
A fundamental result in distributed computing shows that in a purely asynchronous system with even one possible process crash, no deterministic consensus algorithm can guarantee both:
Perfect safety, and
Guaranteed termination.
This means that Paxos cannot guarantee progress in every possible asynchronous execution while also maintaining safety.
Guaranteed progress requires an additional source of coordination or unpredictability, such as:
Randomization.
Timeouts.
Timing assumptions.
A mechanism that chooses one active leader.
17. Leaders and Practical Liveness
Practical Paxos systems usually designate a distinguished proposer, commonly called the leader.
The leader:
Initiates proposals.
Assigns or selects proposal numbers.
Receives client requests.
Coordinates phase one and phase two.
Prevents multiple proposers from continuously competing.
If the leader remains stable and can communicate with a majority of acceptors, it can eventually complete proposals. If another proposer has used a higher number, the leader selects an even higher number and retries.
Leader Election Is for Liveness
Leader election is not part of Paxos’s fundamental safety guarantee.
If leader election fails:
No leader may propose new values, causing the system to stop making progress.
Multiple processes may believe they are leaders, causing livelock.
Nevertheless, Paxos remains safe:
Two different values cannot both be chosen.
A faulty election mechanism may delay decisions, but it cannot make the system choose inconsistent values.
The leader exists primarily to break symmetry and improve liveness.
Paxos safety holds regardless of whether leader election succeeds; leader election is used to make progress more likely.
18. State Machine Replication
Paxos chooses one value for one consensus instance. A complete fault-tolerant service usually needs to agree on a long sequence of commands.
This is achieved through state machine replication.
Deterministic State Machines
A state machine:
Begins in an initial state.
Receives commands.
Updates its state for each command.
May produce outputs.
A state machine is deterministic if the same initial state and the same ordered sequence of commands always produce the same states and outputs.
For example, a calculator that starts at zero and receives the commands “add five” and “add three” will consistently reach eight.
Replicating the State Machine
State machine replication runs identical copies of the deterministic state machine on multiple servers.
If every replica:
Starts from the same initial state.
Executes the same commands.
Executes them in the same order.
then every replica produces the same results and maintains the same state.
The key challenge is therefore not replicating the program itself. It is establishing a single, agreed-upon command order.
One Paxos Instance per Log Slot
Paxos can be run repeatedly, with one consensus instance for each position in a command log:
Paxos instance 1 chooses command 1.
Paxos instance 2 chooses command 2.
Paxos instance 3 chooses command 3.
This continues indefinitely.
Each server may act as a proposer, acceptor, and learner for every instance.
The result is a fault-tolerant, totally ordered log of commands.
19. Processing Commands in a Replicated Service
In a typical system:
A client sends a command to the current leader.
The leader identifies the next available log position.
The leader proposes the client command for that Paxos instance.
Paxos causes one command to be chosen for that position.
All replicas learn the chosen command.
Each replica executes the command after completing all earlier positions.
For example, if commands through position 134 have already been chosen, the leader may assign the next client command to position 135.
Paxos ensures that only one command can be chosen for slot 135, even if:
Another server proposes a different command.
Messages are delayed.
A leader crashes.
Multiple leaders temporarily compete.
Once every replica learns the command for slot 135, it executes that command after positions 1 through 134. Because all replicas execute the same deterministic sequence, they maintain equivalent states.
20. Filling Gaps After Leader Failure
A leader may fail while commands are being proposed. This can leave gaps in the log.
For example:
Commands through position 134 are known.
Commands 138 and 139 may also have been partially proposed.
Positions 135, 136, and 137 are uncertain or empty.
Replicas cannot simply skip the missing positions because state machine execution depends on a contiguous order.
A new leader fills the gaps by running phase one for each missing slot.
Recovering a Partially Accepted Command
During phase one for a missing slot, acceptors may report that they previously accepted a command.
If the highest-numbered accepted proposal for slot 135 contains a command, the new leader must propose that same command in phase two. P2C prevents the leader from replacing it with an unrelated command.
This protects commands that may already have been close to being chosen.
Using a No-Operation Command
If no acceptor reports a previously accepted command for a missing slot, the new leader proposes a no-op command.
A no-op:
Occupies the missing log position.
Produces no meaningful state change.
Allows later commands to be executed in order.
For example, the leader might fill slot 136 with a no-op, while recovering an earlier command for slot 135 and another command for slot 137.
Once all gaps are filled, the log becomes contiguous and the leader can resume assigning new client commands.
21. Paxos Efficiency in the Normal Case
The two-phase structure is essential for safety, but running both phases for every command would be expensive.
A stable leader can improve efficiency by maintaining standing promises from acceptors for future proposal numbers or instances.
In the normal case:
The leader has already completed the prepare phase.
A client command arrives.
The leader sends an accept request directly.
A majority of acceptors responds.
Thus, normal operation may require only the phase-two round trip:
One message from the leader to acceptors.
Responses from a majority.
This makes the common-case communication cost close to one round trip, which is considered essentially optimal for fault-tolerant agreement under the model.
Phase one is still required when:
A new leader takes over.
A higher proposal number is needed.
The leader must recover uncertain history.
Existing promises cannot be reused safely.
22. Dynamic Reconfiguration
Distributed systems often need to change their membership:
Add a new server.
Remove a failed server.
Replace outdated hardware.
Change the set of acceptors.
Paxos can manage this through state machine replication.
The current configuration can itself be represented as part of the replicated state. A configuration change becomes a special command, such as:
Add server Z.
Remove server Y.
Replace one acceptor with another.
The system uses Paxos to choose this configuration command for a particular log position K.
After every replica executes the command:
Each replica updates its local membership information.
The new acceptor set can be used from a later position, such as K+1.
The consensus group changes through the same agreement mechanism that maintains ordinary application state.
This allows a system to implement sophisticated reconfiguration while preserving a consistent view of membership.
23. Overall Significance of Paxos
Paxos builds fault-tolerant consensus from a small set of logical ideas:
Majority quorums ensure that any two successful decisions overlap.
Proposal numbers order competing attempts.
Promises prevent older proposals from interfering with newer ones.
Phase-one history gathering ensures that later proposals preserve earlier accepted values.
Phase-two acceptance establishes when a proposal has actually been chosen.
Stable storage preserves safety across crashes and restarts.
Learners disseminate decisions to the rest of the system.
Leaders improve liveness by preventing proposer competition.
Repeated instances transform single-value consensus into an ordered replicated log.
The central distinction is between safety and liveness:
Paxos is designed so that conflicting values cannot both be chosen.
Progress may stop under extreme asynchrony, failures, or proposer competition.
Leader election, timeouts, and related mechanisms help restore progress.
These mechanisms are not required for the core safety proof.
Paxos therefore demonstrates how unreliable components can be combined into a reliable service through carefully maintained invariants. Its ideas have influenced many systems for databases, configuration management, distributed storage, replicated logs, and other infrastructure requiring consistent agreement.

Ask anything
We've read this whole study set, so questions about it get the best answers.