Last modified: March 23, 2026

This article is written in: 🇺🇸

Linearizability

Linearizability is a consistency model that makes a distributed system appear as if there is only a single copy of the data, and every operation takes effect atomically at some point between its invocation and its response. Even when data is replicated across multiple nodes, a linearizable system guarantees that clients always see the most recent write.

Client A (Write x=1)        Client B (Read x)        Client C (Read x)
        |                            |                         |
   t0   |------- write(x,1) ------->|                         |
        |                           |                         |
   t1   |                     [write completes]               |
        |                           |                         |
   t2   |                           |------- read(x) ------->|
        |                           |                         |
   t3   |                           |    returns x=1          |
        |                           |                         |
   t4   |                           |          |--- read(x) ->|
        |                           |          |              |
   t5   |                           |          | returns x=1  |
        |                           |          |              |
        v                           v          v              v

   +------------+            +------------+           +------------+
   |  Replica 1 |  --------> |  Replica 2 |  -------> |  Replica 3 |
   |   x = 1    |  replicate |   x = 1    | replicate |   x = 1    |
   +------------+            +------------+           +------------+
        All replicas converge so every read reflects the latest write

Linearizability vs Serializability

These two terms sound similar but describe different guarantees. Serializability is a property of transactions in a database, while linearizability is a property of individual read and write operations on a register or object.

Serializability (Transaction-level)        Linearizability (Operation-level)
   +-----------------------------------+      +-----------------------------------+
   |  Tx1: Read A, Write B             |      |  Op1: Write(x, 5)   at t=0       |
   |  Tx2: Read B, Write A             |      |  Op2: Read(x) => 5  at t=1       |
   |                                   |      |  Op3: Write(x, 8)   at t=2       |
   |  Result equivalent to Tx1->Tx2    |      |  Op4: Read(x) => 8  at t=3       |
   |  OR Tx2->Tx1 (any serial order)   |      |  (must respect real-time order)   |
   +-----------------------------------+      +-----------------------------------+

Real-World Examples

Linearizability matters in many practical scenarios where stale data can cause correctness problems.

Ordering

To achieve linearizability, an ordering mechanism for data operations is required. Without a shared global clock, distributed systems must use logical clocks or consensus protocols to agree on operation order.

Node A                     Node B                     Node C
   counter=0                  counter=0                  counter=0
      |                          |                          |
      |-- send(counter=1) ----->|                          |
      |                         |-- recv, set counter=2 -->|
      |                         |                          |-- counter=3
      |                         |                          |
      |<-- send(counter=4) ------------------------------ |
      |                         |                          |
   counter=5                    |                          |
      |                         |                          |
      v                         v                          v

   Lamport Timestamp = (counter, nodeId)
   Example ordering:  (1,A) < (2,B) < (3,C) < (4,C) < (5,A)

Total Order Broadcast

Total order broadcast is a protocol for exchanging messages between nodes that guarantees two key properties: reliable delivery and total ordering. It serves as the foundation for implementing linearizable systems and state machine replication.

Client Request              Total Order Broadcast Layer
       |
       v
   +--------+       +-------------------------------------------+
   | Submit  | ----> |  Assign global sequence number            |
   | Message |       |  Broadcast to all nodes in order          |
   +--------+       +-------------------------------------------+
                          |              |              |
                          v              v              v
                     +---------+    +---------+    +---------+
                     | Node A  |    | Node B  |    | Node C  |
                     | msg #1  |    | msg #1  |    | msg #1  |
                     | msg #2  |    | msg #2  |    | msg #2  |
                     | msg #3  |    | msg #3  |    | msg #3  |
                     +---------+    +---------+    +---------+
                     All nodes deliver messages in the same order

CAP Theorem Implications

The CAP theorem states that a distributed system can provide at most two of three guarantees simultaneously: Consistency (linearizability), Availability, and Partition tolerance. Since network partitions are unavoidable in practice, the real choice is between consistency and availability during a partition.

Consistency (C)
                              /      \
                             /        \
                            /    CP    \
                           /   systems  \
                          /              \
                         /________________\
                        /                  \
          Availability (A) ----------- Partition Tolerance (P)
                         \    AP systems   /
                          \               /
                           \_____________/

   Network partitions are inevitable, so the practical trade-off
   is between Consistency and Availability during a partition.

Cost of Linearizability

Linearizability is a strong guarantee, but it comes with measurable performance and availability costs that engineers must consider when designing a system.

Consistency Models Comparison

Model Guarantee Latency Example Systems
Linearizability Reads always return the latest write; real-time ordering Highest etcd, ZooKeeper, Spanner
Sequential Consistency All nodes see operations in the same order, but not necessarily real-time High ZooKeeper (for some operations)
Causal Consistency Operations that are causally related are seen in order; concurrent operations may differ Medium MongoDB (causal sessions)
Eventual Consistency All replicas converge eventually, but reads may return stale data temporarily Lowest Cassandra, DynamoDB, Riak
Strict Serializability Combines serializability and linearizability for the strongest guarantee Highest CockroachDB, Spanner

Distributed Transactions and Consensus

Distributed transactions coordinate writes across multiple nodes. The most common protocol is two-phase commit (2PC), which ensures all participants either commit or abort a transaction together.

Coordinator                  Participant A             Participant B
       |                             |                          |
       |--- prepare --------------->|                          |
       |--- prepare ----------------------------------------->|
       |                             |                          |
       |<-- vote yes ---------------|                          |
       |<-- vote yes ------------------------------------------|
       |                             |                          |
       | (write decision to log)     |                          |
       |                             |                          |
       |--- commit ---------------->|                          |
       |--- commit ------------------------------------------>|
       |                             |                          |
       |<-- ack --------------------|                          |
       |<-- ack ------------------------------------------------|
       |                             |                          |

Quorum and Consensus Algorithms

Consensus algorithms use a majority (quorum) of nodes to make decisions, avoiding the single-point-of-failure problem that plagues two-phase commit. They form the backbone of modern fault-tolerant distributed systems.