Linearizability (also called atomic consistency, strong consistency, or external consistency) is the strongest single-object consistency model. Its guarantee is simple: after a write completes, all subsequent reads must return the written value โ from any node, from any client, anywhere in the system.
More formally: a system is linearizable if operations appear to have been executed atomically on a single copy of the data at some point between their invocation and response. The system behaves as if there is a single, shared register, and every read returns the value of the most recently committed write.
Crucially, linearizability is a recency guarantee, not a transaction isolation guarantee. It applies to individual operations on individual objects. It says nothing about multi-object consistency โ that is the domain of serializability.
Linearizability vs. Serializability
Linearizability
Single-object recency guarantee. Reads return the most recently written value. Time-based: there is a real-time ordering of operations. Does not concern transactions or multi-object consistency.
Serializability
Multi-object isolation guarantee. Transactions appear to execute one at a time in some serial order. Order does not have to match real time โ snapshot isolation satisfies serializability but not linearizability (stale reads are allowed).
Strict serializability = linearizability + serializability. Both recency and transaction isolation guaranteed. This is what PostgreSQL provides with serializable isolation on a single node.
Distributed Locks and Leader Election
Only one node must hold the lock or be the leader at a time. Requires linearizable compare-and-set (CAS) โ "set this value only if it is currently X." Linearizability ensures the CAS is atomic across all replicas.
Systems: ZooKeeper, etcd (Raft-based), Apache Curator
Uniqueness Constraints
Username or email uniqueness across concurrent registrations. Two concurrent requests to register the same username must result in exactly one succeeding. Requires linearizable writes.
Systems: PostgreSQL serializable isolation, single-leader database with uniqueness constraint
Cross-Channel Timing Dependencies
User sets account private on device A, then uploads photo on device B. Photo service must see the "private" setting before allowing the photo. Without linearizability (using Lamport clocks instead), the photo may be uploaded as public.
Systems: Single database with linearizable reads, or Spanner TrueTime