distributed-systems · intermediate
Consistency Models — From Strong to Eventual
Start here
A consistency model is a rulebook for what clients may observe.
When many users read and write, and when data has multiple copies, the system must answer questions like:
- Can I see a write before it is fully committed everywhere?
- Can two users see different orders of events?
- If I read twice, can time go backward?
This lesson is progressive. You do not need a PhD. We will climb from everyday ideas to a few standard names used in real systems.
What you will learn
- Explain what a consistency model is protecting.
- Place models on a rough spectrum from strong to weak.
- Define linearizability and serializability in plain language (and how they differ).
- Define sequential, causal, and eventual consistency at a usable level.
- Connect models to CAP, latency, and multi-region design.
- Pick models per data class with a worked social + payments example.
- Know what to study next (quorums, transactions).
What you should know first
| Topic | Why |
|---|---|
| Strong vs Eventual Consistency | Big-picture trade-off |
| CAP Theorem | Partitions and C vs A |
| Client/server requests | Reads and writes as operations |
Words you need before we begin
| Term | Plain English |
|---|---|
| Operation | A read or write (or transaction) issued by a client. |
| History | The story of operations and what values were seen. |
| Consistency model | Which histories are allowed. |
| Linearizability | Strong single-object order as if one copy, respecting real time. |
| Serializability | Transactions behave as if run one-at-a-time in some order. |
| Causal consistency | If A could have caused B, everyone sees A before B. |
| Eventual consistency | Replicas converge if updates stop; interim disagreement allowed. |
| Stale | Out of date relative to a newer write. |
| Session | A client’s ongoing sequence of operations (often one user/device). |
Simple story: the group chat timeline
Four friends message in a chat.
- Strong order everyone shares: all phones show the exact same global order of messages, updating live. Hard when phones are offline.
- Causal order: if you reply to a message, nobody sees the reply before the original.
- Eventual: while offline, phones diverge; when online again, messages sync and settle.
Where the analogy stops: databases formalize these ideas with math; apps also have UI rules (“sending…” state) that are not the store’s model.
The problem: concurrency makes “obvious” order unclear
On one single-threaded program, operations happen in a clear sequence.
In a distributed system:
- Client A writes
x = 1 - Client B writes
x = 2at “about the same time” - Client C reads
Step-by-step explanation
Step 1 — Models are contracts, not vibes
When a vendor says “strongly consistent reads,” ask:
- Consistent with what model?
- Across which keys / transactions?
- With what failure behavior?
Step 2 — A simple spectrum (not perfect, but useful)
From stronger / more coordinated → weaker / more scalable (roughly):
- Linearizability (per object, real-time)
- Sequential consistency
- Causal consistency
- Session guarantees (read-your-writes, monotonic reads)
- Eventual consistency
Step 3 — Linearizability (plain English)
Linearizability means each operation on an object appears to take effect instantly at some point between its start and end, and all clients agree on that order, respecting real-time order when operations do not overlap.
Intuition:
- There is one global up-to-date object.
- Once a write completes, any read that starts later sees it (or a newer write).
Step 4 — Serializability (plain English)
Serializability applies to transactions (bundles of operations):
The result looks as if transactions ran one after another in some order — not interleaved in a messy way that breaks application invariants.
Example invariant: “transfer money: debit A and credit B together.” Serializability helps such multi-step logic appear atomic as a group.
Note: a system can be serializable yet allow behaviors that linearizability would forbid, depending on timing details. You do not need the edge cases on day one — remember transactions vs single operations.
Step 5 — Sequential consistency
Sequential consistency says there is a single global order of operations that all clients agree on, and each client’s own operations appear in the order it issued them — but that global order does not have to respect real-time as strictly as linearizability.
Intuition: everyone agrees on a story order, but the story may rearrange overlapping real-time operations more freely than linearizability allows.
Step 6 — Causal consistency
Causal consistency preserves cause and effect:
- If you write B after reading A (or otherwise depending on A), then anyone who sees B must be able to see A first.
- Concurrent writes with no causal link may be seen in different orders by different clients.
Step 7 — Session guarantees (practical everyday tools)
Even under weaker global models, systems often try to provide:
| Guarantee | Promise |
|---|---|
| Read-your-writes | After you write, your later reads see it |
| Monotonic reads | Your successive reads never go backward |
| Monotonic writes | Your writes are observed in order you sent them |
| Writes-follow-reads | Writes you do after a read are ordered after what you read |
These make UX saner without global strong consistency.
Step 8 — Eventual consistency revisited
Eventual consistency allows temporary disagreement. If updates stop, replicas converge.
It is the weakest common product term — and the most misused. Always ask about:
- Conflict resolution
- Typical lag
- Session guarantees
- Whether deletes can resurrect (surprising under some designs)
Step 9 — How to choose (beginner decision guide)
Ask:
- Multi-key business invariant? Lean toward transactional serializability (or careful workflows).
- Single key, must never look stale after success? Lean linearizable / strong primary reads.
- Collaborative / social / multi-region chatty data? Causal or session + eventual may fit.
- Can you show “updating…” UI? Weaker models become acceptable.
- What is the merge story? If you cannot merge, do not allow concurrent multi-writer updates.
Visual mental model
Spectrum
flowchart LR
L[Linearizability] --> S[Sequential]
S --> C[Causal]
C --> G[Session guarantees]
G --> E[Eventual]
Learning question: Which direction usually needs more coordination?
Caption: Left = stronger, more coordination; right = weaker, more scale flexibility.
Transactions vs single ops
flowchart TB
subgraph ops [Single operations]
Lin[Linearizability]
end
subgraph tx [Transactions]
Ser[Serializability]
end
App[Application invariants] --> tx
App --> ops
Learning question: Which box helps “debit + credit as one unit” most directly?
Caption: Multi-key atomic logic → transactions/serializability family.
Complete worked example: social app + wallet
Product pieces
- User bio text
- Follow graph
- Feed posts
- Wallet balance for tips
Model choices
| Data | Model leaning | Rationale |
|---|---|---|
| Bio text | Eventual + read-your-writes | Low harm if friend sees lag |
| Follow graph | Causal / careful eventual | “Follow then see posts” feels causal |
| Feed posts | Timeline ordering ≈ causal per author | Global linear order of all posts worldwide is unnecessary |
| Wallet tips | Strong / transactional | Money invariants |
Partition behavior notes
- Bio: both regions may accept edits; last-write-wins or field-level merge.
- Wallet: majority quorum or single primary; minority refuses spends.
Outcome
The app is not “one consistency model.” It is a portfolio of models. That is normal and healthy.
How it works in production
Where models show up in tools
- Dynamo-style stores: tunable quorums, often eventual by default
- etcd / ZooKeeper / Consul: linearizable ops for coordination
- Relational DBs: isolation levels (Read Committed, Snapshot, Serializable)
- Distributed SQL: vary by product
Testing consistency assumptions
- Jepsen-style tests (advanced)
- Application-level assertions under fault injection
- Chaos for partitions
Documentation duty
Write down for each critical data type:
- Intended model
- Acceptable staleness
- Conflict policy
Failure modes
| Mistake | Result |
|---|---|
| Assume serializable; use read-committed | Lost updates / anomalies |
| Assume linearizable reads from any replica | Stale admin decisions |
| Eventual multi-writer without merge | Silent data loss |
| Hide lag forever | Support hell |
| One global lock for everything | System “consistent” but unusable latency |
Trade-offs
| Stronger model | Weaker model |
|---|---|
| Easier app reasoning | Harder app reasoning |
| More coordination latency | Lower local latency |
| More refusal under partitions | More availability with divergence |
| Great for money | Great for social scale |
Compare with related concepts
| Term | Focus |
|---|---|
| Consistency model | Allowed observation histories |
| Isolation level | Transaction interleaving rules in DBs |
| Durability | Survival after crash |
| Freshness / lag | How old a replica might be |
| CAP | Partition-time C vs A tension |
Common misunderstandings
- “Serializable means linearizable.”
- “Eventual will fix itself in N seconds.”
- “More replicas make consistency stronger.”
- “We use Kubernetes so we are linearizable.”
- “Weak models are unprofessional.”
Check your understanding
Serializability
Eventual consistency only
Bandwidth consistency
TTL consistency
Causal consistency
Unconditional eventual with no ordering
RAID-0 only
Random consistency
Practice
For an online classroom product:
- Assign a model leaning to: grades, course title, live quiz answers, student notes drafts.
- For grades, write one invariant that serializable transactions would protect.
- For notes drafts, describe a conflict when two devices edit offline.
- List two session guarantees that would improve notes UX.
- Explain how a partition between regions should treat grade submission vs draft sync differently.
Revision summary
- Consistency models = allowed observation rules.
- Stronger models coordinate more; weaker models scale more easily.
- Linearizability ≈ single-copy real-time object behavior.
- Serializability ≈ transactions as one-at-a-time.
- Causal and session guarantees are practical middle layers.
- Eventual needs merge policy and lag metrics.
- Choose per data, not per logo.
Glossary
| Term | Definition | Example |
|---|---|---|
| Consistency model | Rules for allowed read/write histories | Linearizability contract |
| Linearizability | Single-copy real-time object order | Config flag flip seen everywhere after ack |
| Serializability | Transactions equivalent to some serial order | Money transfer txns |
| Sequential consistency | Single order agreed by all; weaker real-time | Agreed story order |
| Causal consistency | Cause before effect preserved | Reply after original |
| Session guarantee | Per-client nicer properties | Read-your-writes |
| Eventual consistency | Converge if writes stop | Bio replicas catch up |
| Anomaly | History forbidden by a model but produced by a weaker system | Lost update |
Abbreviations and terminology
| Short | Full / note |
|---|---|
| CAP | Consistency, Availability, Partition tolerance |
| txn | Transaction |
| RY W | Read-your-writes (session guarantee) |
| LWW | Last-Write-Wins (simple conflict policy) |
| CRDT | Conflict-free Replicated Data Type |
| isolation level | Database setting controlling concurrent txn anomalies |
What to learn next
Primary next lesson: Quorum reads vs quorum writes
Also useful: data replication and ACID/transaction lessons when you implement multi-key invariants.
Track: Distributed Systems
Previous: CAP, Consistency & Idempotency
Next: Strong vs Eventual Consistency — Trade-offs in Distributed Systems
Series: CAP, Consistency & Quorums
- CAP Theorem — Consistency, Availability, and Partition Tolerance
- Consistency Models — From Strong to Eventual (this guide)
- Strong vs Eventual Consistency — Trade-offs in Distributed Systems
- CAP, Consistency & Idempotency
- Quorum Reads vs Quorum Writes
By Shubham Jain