Distributed Consistency
5 exercises — master consistency model vocabulary: linearizability vs. serializability, eventual consistency, snapshot isolation, write skew, read-your-writes consistency patterns, and CRDTs.
0 / 5 completed
Consistency model quick reference
- Linearizability — single-object, real-time ordering: operation appears atomic at one instant.
- Serializability — multi-object transactions: result equivalent to some serial execution; no real-time constraint.
- Strict serializability — both; used in Spanner, FoundationDB.
- Snapshot isolation — reads a consistent snapshot; prevents dirty + non-repeatable reads but not write skew.
- Write skew — two transactions read overlapping data, write non-overlapping keys, violate a constraint.
- Eventual consistency — convergence guaranteed, no timing bound. Practical lag: milliseconds to seconds.
- Read-your-writes — session guarantee; achievable with sticky routing, LSN tracking, or client-side cache.
- CRDT — conflict-free merge; G-Counter increments require no coordination.
1 / 5
An interviewer asks: "What is the difference between linearizability and serializability? Can a system be serializable but not linearizable?"
Linearizability = real-time ordering of single-object operations. Serializability = transaction equivalence to some serial order (no real-time constraint).
Linearizability:
• Guarantees operations respond as if they were executed atomically at a single point in real time
• If operation A completes before operation B starts, B must observe A's effect
• Applies to individual read/write operations on a register/object
• Example: after a write to X completes, any subsequent read from any replica returns the written value
• Where it matters: distributed locks, counters, compare-and-swap, leader coordination
Serializability:
• Guarantees that concurrent transactions produce results equivalent to some serial execution
• Does NOT constrain which serial order — it could be A then B or B then A, regardless of real-time clock order
• Applies to multi-key transactions (databases)
• Example: two concurrent bank transfers may appear to have executed in any order, but the result is internally consistent
Strict serializability (strongest):
• Combines both: transactions appear to execute atomically, AND in real-time order
• Implies both linearizability and serializability
• Achieved by: Google Spanner (TrueTime), FoundationDB, some CockroachDB configurations
• High cost: global coordination, high latency
The consistency hierarchy (strongest → weakest):
• Linearizability — single-object consistency: operations appear atomic with real-time ordering
• Serializability — multi-object transaction consistency: concurrent transactions equivalent to some serial order
• Strict serializability — combines both; strongest isolation/consistency guarantee
• Consistency model — the contract between a distributed system and its clients about observable behaviour
Linearizability:
• Guarantees operations respond as if they were executed atomically at a single point in real time
• If operation A completes before operation B starts, B must observe A's effect
• Applies to individual read/write operations on a register/object
• Example: after a write to X completes, any subsequent read from any replica returns the written value
• Where it matters: distributed locks, counters, compare-and-swap, leader coordination
Serializability:
• Guarantees that concurrent transactions produce results equivalent to some serial execution
• Does NOT constrain which serial order — it could be A then B or B then A, regardless of real-time clock order
• Applies to multi-key transactions (databases)
• Example: two concurrent bank transfers may appear to have executed in any order, but the result is internally consistent
Strict serializability (strongest):
• Combines both: transactions appear to execute atomically, AND in real-time order
• Implies both linearizability and serializability
• Achieved by: Google Spanner (TrueTime), FoundationDB, some CockroachDB configurations
• High cost: global coordination, high latency
The consistency hierarchy (strongest → weakest):
Strict serializability (linearizable + serializable)
↓
Linearizability (single objects, real-time)
↓
Serializability (transactions, no real-time order)
↓
Snapshot isolation (reads from consistent snapshot)
↓
Read committed (no dirty reads)
↓
Eventual consistency (converge, no ordering)
Key vocabulary:• Linearizability — single-object consistency: operations appear atomic with real-time ordering
• Serializability — multi-object transaction consistency: concurrent transactions equivalent to some serial order
• Strict serializability — combines both; strongest isolation/consistency guarantee
• Consistency model — the contract between a distributed system and its clients about observable behaviour