Consistency Models
Navigate the spectrum from eventual and causal consistency up to linearizability and quorums.
In plain words
Consistency models describe how fresh the data you read is guaranteed to be. Some promise you always see the latest value; others allow a short delay before everyone agrees.
Think of it like…
Linearizability is a live scoreboard everyone sees flip at the exact same instant; causal consistency ensures a reply never appears before the comment it answered.
Where you’ve seen it
After you post a comment, you should see it right away (read-your-writes), even if a friend in another country sees it a second later (eventual consistency).
Words you’ll hear
- Strong consistency
- Reads always return the latest write.
- Eventual consistency
- All copies will agree eventually, but reads may be briefly stale.
- Read-your-writes
- You always see your own updates.
- Replication lag
- The delay before a replica receives the latest write.
Visual diagram
Theory & deep dive
Not all "consistency" is created equal
Between "every machine freezes until everyone agrees" and "anything goes," there is a rich spectrum. Most real apps don’t need global linearizability everywhere - they need read-your-writes (when I post a photo, I immediately see it on refresh) and causal consistency (a reply never appears before the original comment).
For leaderless databases like Dynamo/Cassandra, quorums (W + R > N) ensure that the nodes you read from overlap with at least one node that received the latest write.
How it works, step by step
Step 1 of 41. Eventual Consistency (baseline async)
If writes stop, all replicas eventually converge. Cheapest and fastest, though readers may temporarily see stale or out-of-order states.
- Write RTT
- 1 local node
- Risk
- Stale / out-of-order
When to use it & trade-offs
What it is
Consistency models define the exact contract a data store gives clients about when a write becomes visible to subsequent reads across replicas.
Why it matters: “Strong” vs. “eventual” is too coarse; knowing read-your-writes, causal ordering, and Dynamo-style quorums lets you pick the cheapest model that avoids user-visible bugs.
When to reach for it
- Read-your-writes tokens for user settings, posts, and CRUD dashboards
- Linearizability for distributed locks, inventory reservation, and unique constraints
- Causal ordering for chat replies, threaded comments, and access-revoke-before-share flows
When to avoid or be careful
- Paying global linearizable latency for analytics counters or public timelines
- Assuming
W + R > Nalone guarantees linearizability without read-repair or conflict resolution
Consistency Spectrum
Strengths: Behaves like a single atomic copy of data in real time.
Watch out: Requires consensus / cross-node coordination on reads and writes.
Strengths: Preserves logical cause-and-effect with low latency and high availability.
Watch out: Requires passing version vectors or LSN tokens across requests.
Strengths: Pick W=1, R=N for fast writes or W=N, R=1 for fast reads while overlapping.
Watch out: Still needs read-repair or strict serializability for true linearizability under concurrent writes.
Interview signals & numbers to know
When this topic comes up
- read-your-writes
- monotonic reads
- quorum W+R>N
- vector clocks
- comment appears before post
Benchmarks & rules of thumb
- Quorum overlap rule
- W + R > N
- Typical N=3 quorum
- W=2, R=2 (survives 1 failure)
- Typical N=5 quorum
- W=3, R=3 (survives 2 failures)
- Sloppy quorum risk
- Temporary stale reads
Common mistakes & follow-ups
Common interview mistakes
- Confusing database ACID “Isolation” (concurrent transaction interference) with distributed CAP “Consistency” (replica freshness)
- Using Last-Write-Wins (LWW) with unsynchronized wall clocks (NTP clock skew silently drops newer writes)
- Forgetting read-repair or anti-entropy Merkle trees in leaderless quorum stores
Likely interviewer follow-ups
- How can two users see a reply before the parent post under eventual consistency, and how does causal consistency stop it?
- Why is Last-Write-Wins with wall-clock timestamps dangerous in distributed writes?
- How do vector clocks or Hybrid Logical Clocks (HLC) improve conflict detection?
Knowledge check
Put it into practice
Design full architectures with AI feedback
Apply Consistency Models inside real High-Level Design prompts or review Q&A flashcards.