Notesdistributed🌱 seedling
Consistency Model
Also: Consistency Guarantee · Data Consistency Model · Consistency Level
The contract that says which results a read may return while replicas disagree. It's a safety property over histories (who issued what, and what they got back), so it can be tested by recording a history and checking it.
Why it exists
Replicated data is always briefly inconsistent: writes are in flight, replicas lag, partitions cut regions off. Programmers need to know what they can rely on during that window. "Strongly consistent" is not a spec; a named model is.
How it works
Models nest: each allows every history the stronger one allows, and more.
- Linearizability: behaves like one copy, respecting real time.
- Sequential Consistency: one agreed order, may lag real time.
- Causal Consistency: cause before effect; concurrent writes in any order.
- Session guarantees: Read-Your-Writes Consistency, Monotonic Reads, monotonic writes, writes-follow-reads.
- Eventual Consistency: convergence only.
- Availability classes: totally available (any non-failing node answers in a partition), sticky available (if each client sticks to one replica), or unavailable (some node must stop). Linearizable and sequential are the last.
Trade-offs
| Stronger model | Weaker model |
|---|---|
| fewer anomalies, simpler application code | more anomalies to design around |
| coordination on every request (latency) | answers locally |
| stops during a partition | stays available |
In practice
- Many stores let you pick per request: DynamoDB strongly vs eventually consistent reads, Cassandra consistency levels, MongoDB read and write concerns, etcd's serializable flag.
- Single-object models are distinct from transaction Isolation Levels; strict serializability combines linearizability with serializability.
Pitfalls
- Trusting vendor labels. Jepsen has found many stores violating their own documented models.
- Forgetting that the model only covers what goes through the store: side channels (queues, phone calls) create causality it can't see.
Connections
- Part of
- Distributed Systems
- Learn first
- Leader-Based ReplicationReplication Lag
Recall
These cards are also in your review deck, scheduled with spaced repetition.