Interview's MateSystem Design
Interview's Mate

System Design

Architecture & trade-offs

Visualizer

DSA Visualizer
All 32 lessons
Custom Playground
Try your own examples

Learning

System Design
31 architecture topics
SQL Learning
160 foundations → production topics
AI Engineering
160 LLM → backend topics
Data Science
160 Python → MLOps topics
Data Engineer
160 SQL → streaming topics
Docker
160 Docker learning topics
Kubernetes
160 K8s fundamentals → cloud
Java LearnSoon
Coming soon
Python Learn
Interview Q&A & internals
JavaScript Learn
Closures, async & DOM Q&A
Tech Learn
Search, practise & track Q&A
AI DSA Practice
Solve coding problems
Theme
Home
System Design topics
Lesson 16/ 31
Distributed Systems & Architecture

Consistency Models

Navigate the spectrum from eventual and causal consistency up to linearizability and quorums.

AdvancedLinearizable · Causal · Quorums3 quiz questions0/2 subtopics done
Practice in AI HLD
In plain wordsDiagramTheorySubtopics (2)Step by stepWhen to use itInterview cluesMistakes to avoidQuiz (3)Practice
Deep-dive subtopics (2) - 0/2 completed
Linearizability, Causal & Read-Your-Writes

Match user expectations without paying unnecessary global consensus costs.

Advanced
Quorum Reads & Writes (W + R > N)

Tune consistency vs. availability in leaderless stores by adjusting N, W, and R.

Advanced

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

Loading interactive diagram
Loading interactive exercise

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.

Key takeaway: Pick the weakest consistency model that avoids user-visible bugs - it saves latency and improves availability.

How it works, step by step

Step 1 of 4
Async Replicas

1. 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.

Lowest latency · fine for counters, feeds, public catalogs
Key numbers at this step
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 > N alone guarantees linearizability without read-repair or conflict resolution

Consistency Spectrum

Linearizability (External Consistency)
Best for: Leader locks, unique usernames, financial balances

Strengths: Behaves like a single atomic copy of data in real time.

Watch out: Requires consensus / cross-node coordination on reads and writes.

Causal / Read-Your-Writes
Best for: Comment threads, user profile edits, collaborative apps

Strengths: Preserves logical cause-and-effect with low latency and high availability.

Watch out: Requires passing version vectors or LSN tokens across requests.

Tunable Quorum (W + R > N)
Best for: Leaderless stores (Cassandra, Dynamo) tuning read vs. write speed

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?
Interview tip: Distinguish “Read-Your-Writes” from full “Linearizability” - interviewers love seeing that you know cheaper session guarantees often solve the UX bug.

Knowledge check

Loading quiz

Put it into practice

Design full architectures with AI feedback

Apply Consistency Models inside real High-Level Design prompts or review Q&A flashcards.

Open AI HLD Practice →SD Interview Q&A
Previous topic
CAP Theorem & PACELC
Next topic
Distributed Consensus & Coordination