Consistency Models in Distributed Systems
Compare linearizable, sequential, causal, session, and eventual consistency using a stale-read timeline, safety and liveness, and application invariants.
Consistency models describe which read and write histories a system may expose. This hub compares linearizable, sequential, causal, session, and eventual guarantees, then traces how two replicas can return different values while an update is in flight. Eventual consistency permits stale reads but does not by itself decide whether application invariants are preserved; that depends on operations, data models, and conflict handling. Follow the companion guides for CAP, quorums, CRDTs, consensus, and transactions.
Consistency Models in Distributed Systems
A consistency model describes which results readers may observe when operations overlap, replicas lag, or failures interrupt communication. It is a contract between a storage system and its clients. The model alone does not tell you whether an application preserves every business rule; that also depends on the operations and data model.
Compare the guarantees
| Model | What readers can rely on | What it does not imply by itself |
|---|---|---|
| Linearizability | Each operation appears to take effect at one instant between its invocation and response; completed operations respect real-time order. | That every multi-object workflow is one atomic transaction. |
| Sequential consistency | Operations appear in one total order that preserves each process’s program order. | That the total order respects real-time completion order. |
| Causal consistency | Causally related operations are observed in causal order. | A single global order for concurrent operations. |
| Session guarantees | A client session may preserve properties such as read-your-writes or monotonic reads, depending on the API. | A global guarantee for other clients or sessions. |
| Eventual consistency | If updates stop and the system’s convergence assumptions hold, replicas eventually converge. | A freshness bound, conflict-free updates, or preservation of application invariants. |
Linearizability is a formal correctness condition for concurrent objects. Sequential consistency preserves each process’s operation order but does not require real-time order. See Herlihy and Wing’s linearizability paper and Lamport’s paper on sequential consistency. Product terms such as “strong” and “eventual” can cover different API scopes, so check the actual database or service contract.
A stale-read timeline
This illustrative timeline shows why two clients can temporarily observe different values under an eventually consistent replication policy:
sequenceDiagram
participant A as Client A
participant R1 as Replica 1
participant R2 as Replica 2
participant B as Client B
A->>R1: write x = 1
R1-->>A: acknowledge under configured write policy
Note over R1,R2: Replication of x = 1 is still in flight
A->>R1: read x
R1-->>A: x = 1
B->>R2: read x
R2-->>B: x = 0 (stale)
R1-->>R2: replicate x = 1
B->>R2: read x again
R2-->>B: x = 1
The example assumes the write can be acknowledged before replica 2 receives it. The exact behavior depends on the system’s write policy, replication protocol, and failure handling. Eventual convergence does not say how long the stale interval lasts unless the service separately documents a bound.
Consistency and application invariants
Consistency is not a synonym for “correctness.” A weaker read guarantee can be appropriate for data where temporary staleness is acceptable, such as a cached display value. It can be unsafe for an operation whose invariant depends on current shared state. For example, two clients that each see an inventory count of one might both decrement it unless the operation is coordinated or uses a data type designed to preserve the rule.
When designing a system, write the invariant in ordinary terms first: “a seat can be sold once,” “the balance cannot go below zero,” or “a user sees their own newly posted message.” Then decide which operation must enforce it. A read model may lag while a transactional write path protects the invariant, but the application must explain what users see during that lag.
It also helps to distinguish safety from liveness. A safety property says that a forbidden outcome never occurs. A liveness property says that the system can make progress under stated assumptions. A system may preserve safety by refusing writes during a partition, or favor progress by accepting writes that later need reconciliation. Availability is not a synonym for liveness, and a label such as “eventual” does not automatically guarantee either property without the system’s assumptions.
Session guarantees
A session guarantee narrows a user’s experience without necessarily imposing one global order on all operations. Common examples include:
- Read-your-writes: after a client successfully writes a value, later reads in that session return that value or a newer one.
- Monotonic reads: once a session has observed a version, later reads do not move backward to an older version.
- Monotonic writes: writes from one session are applied in that session’s order.
These guarantees can be implemented by routing a session to an appropriate replica, carrying version metadata, waiting for replication, or using a stronger read policy. The details are system-specific. Verify whether the guarantee applies across reconnects, regions, retries, and different APIs.
A practical selection process
- State the business invariant and identify the operation that must protect it.
- Decide what a stale read would mean to a user or downstream system.
- Identify the required scope: one record, one session, a partition, a transaction, or a global order.
- Check the exact API contract for reads, writes, retries, conflicts, and behavior during partitions.
- Decide how the application handles concurrent updates and reconciliation.
- Test the failure path: delay or drop replication, retry an operation, and check that the invariant still holds.
A consistency level or quorum count is not a complete model on its own. For a product-specific choice, include its replication strategy, failure domain, read and write policies, and transaction semantics.
Continue with focused guides
- CAP theorem explains the consistency and availability trade-off during a network partition.
- PACELC theorem considers latency trade-offs when there is no partition.
- Database replication and column-family databases cover replication and quorum behavior in concrete storage systems.
- CRDTs covers data types designed for replicated updates and merge behavior.
- Paxos and Raft cover consensus protocols.
- Distributed transactions and two-phase commit cover coordination across participants.
- Transaction isolation covers database transaction behavior.
Further Reading
- Herlihy and Wing, “Linearizability: A Correctness Condition for Concurrent Objects”
- Lamport, “How to Make a Multiprocessor Computer That Correctly Executes Multiprocess Programs”
- Bailis et al., “Eventual Consistency Today: Limitations, Extensions, and Beyond”
- DeCandia et al., “Dynamo: Amazon’s Highly Available Key-value Store”
Category
Related Posts
Google Spanner: Globally Distributed SQL at Scale
Google Spanner architecture combining relational model with horizontal scalability, TrueTime API for global consistency, and F1 database implementation.
Gossip Protocol: Scalable State Propagation
Learn how gossip protocols enable scalable state sharing in distributed systems. Covers epidemic broadcast, anti-entropy, SWIM failure detection, and real-world applications like Cassandra and Consul.
Synchronous Replication: Data Consistency Across Nodes
Learn about synchronous replication patterns in distributed databases, including Quorum-based replication and write-ahead log shipping for zero RPO.