Paxos Algorithm
Linearizable Consistency
Distributed Systems
Computer Science
Consistency Models

Does paxos provide true linearizable consistency or not?

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Paxos is a consensus algorithm developed by Leslie Lamport in 1990, primarily used to achieve agreement among unreliable processors in distributed systems. Its objective is to ensure that a cluster of machines will reliably agree on some state (like logs or database commits) even in the face of failures. When discussing distributed systems, particularly databases or transactional systems, it becomes crucial to understand what kind of consistency they provide. In the context of Paxos, a key question is whether it provides true linearizable consistency.

What is Linearizable Consistency?

Linearizable consistency, also termed as atomic or immediate consistency, is a strong form of consistency for distributed systems. In linearizability, every operation appears instantaneous to external observers, occurring without any perceptible delay or overlap with others. Essentially, it ensures that if operation B started after operation A completed, then B logically occurs after A.

Paxos and Consistency

Paxos works by choosing a single value from a set of proposed values through a series of steps involving proposing, preparing, promising, and finally accepting a value. Paxos ensures that once a value has been chosen, subsequent operations must also choose that previously selected value, maintaining consistency across the network.

Here’s a simplified breakdown of how Paxos works:

  1. Prepare: A proposer selects a proposal number nn and sends a prepare request with nn to a majority of acceptors.
  2. Promise: Acceptors respond to the prepare requests by promising not to accept any more proposals numbered less than nn. If they've already accepted proposals, they include the highest-numbered proposal in their response.
  3. Propose: Once the proposer receives responses from a majority of acceptors, it sends a proposal with number nn and value vv (which is one of the values it saw in the responses or a new value if none were accepted before).
  4. Accept: Acceptors now accept the proposal unless they have received a higher-numbered prepare request in the meantime.

Does Paxos Provide Linearizable Consistency?

Paxos in its basic form as defined by Lamport ensures eventual consistency and guarantees that agreed-upon values are consistent across all nodes. For Paxos to achieve linearizable consistency, it needs an additional layer of synchronization which involves ensuring that no new agree operation (acceptance of value) starts until the previous one is acknowledged by all nodes (or at least a majority considered as quorum).

Thus, while Paxos guarantees that once a value is chosen all nodes will eventually agree on that value, it does not ensure linearizable consistency due to the potential delay between the agreement and the acknowledgment or update across all nodes. Transaction ordering is not inherently enforced in core Paxos, which is required for linearizable consistency.

Enhancements for Linearizability

To achieve linearizability in systems implementing Paxos, additional mechanisms are usually employed. For example, systems may use leases or fencing tokens, where a time-limited lease prevents other operations from proceeding until the earlier operation is fully acknowledged and updated across the system. These mechanisms help to enforce the strict ordering required for linearizable consistency.

Summary Table

FeaturePaxos BasicPaxos with Enhancements
Consistency LevelEventual ConsistencyLinearizable Consistency
Ordering EnforcedNoYes
Majority RequiredFor ConsensusFor Operations (Leases)
Operational ComplexityModerateHigh

In conclusion, while Paxos itself is a breakthrough in achieving consensus across distributed systems, ensuring linearizable consistency requires modifications or additional mechanisms. For critical applications that demand linearizability, understanding these additional requirements and implementing them correctly is crucial.


Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.