Skip to content
LowLevelDesign Mastery

Consistency Models

When everyone sees the same thing (or not)

Consistency answers a fundamental question: When you update data in one place, when do other parts of your system see that change?

Think of it like updating a shared document. Do you want everyone to see changes instantly (strong consistency), or is it okay if they see them a few seconds later (eventual consistency)?

A write setting balance to 100 USD handled two ways: strong consistency updates all nodes immediately, eventual consistency converges within seconds

Consistency isn’t binary—it’s a spectrum from strongest to weakest:

Consistency spectrum from strongest to weakest: strong, sequential, causal, eventual and weak consistency

Understanding how major companies use different consistency models helps illustrate their practical importance:

The Challenge: Banks need to ensure account balances are always accurate. A user’s balance must be the same across all systems immediately after any transaction.

The Solution: Banks use strong consistency:

  • Account Balance: All systems see the same balance immediately
  • Transaction Processing: Locks ensure no double-spending
  • Critical: Money accuracy is more important than speed

Example: User transfers $100:

  • Strong Consistency: Lock Account A → Deduct $100 → Lock Account B → Add $100 → Unlock both
  • Result: Both accounts always show correct balance
  • Trade-off: Slower (waits for locks), but guaranteed accuracy

Impact: Zero incorrect balances. All transactions are accurate. Critical for financial systems.

Eventual Consistency: Social Media Platforms

Section titled “Eventual Consistency: Social Media Platforms”

The Challenge: Social media platforms need fast user experience. Like counts, comments, and posts need to update instantly, but perfect accuracy across all data centers isn’t critical.

The Solution: Social media platforms use eventual consistency:

  • Like Counts: Update immediately on local node, replicate to other nodes asynchronously
  • Posts: Write to local node, propagate to other regions within seconds
  • Trade-off: Temporary inconsistencies acceptable for speed

Example: User likes a post:

  • Eventual Consistency: Update like count locally → Return success → Replicate to other data centers asynchronously
  • Result: User sees instant feedback, other users see update within seconds
  • Trade-off: Fast response, but temporary inconsistencies possible

Impact: Fast user experience. Handles millions of interactions. Acceptable inconsistencies for non-critical data.

The Challenge: Chat applications need to preserve message order. If User B replies to User A’s message, all users must see the original message before the reply.

The Solution: Chat applications use causal consistency:

  • Message Order: Preserves cause-and-effect relationships
  • Threads: Ensures replies appear after original messages
  • Trade-off: Stronger than eventual, but weaker than strong consistency

Example: User A posts message, User B replies:

  • Causal Consistency: Track dependencies → Ensure reply is seen only after original message
  • Result: All users see messages in logical order
  • Trade-off: Preserves causality without global coordination

Impact: Logical message order. No confusion. Better than eventual consistency for chat.

The Challenge: E-commerce platforms have different consistency needs for different data types.

The Solution: E-commerce platforms use hybrid approaches:

  • Product Catalog: Eventual consistency (fast updates, acceptable inconsistencies)
  • Inventory: Strong consistency (prevent overselling)
  • Reviews: Causal consistency (preserve reply order)

Example: Product page load:

  • Product Info: Eventual consistency (fast, may be slightly stale)
  • Inventory: Strong consistency (must be accurate)
  • Reviews: Causal consistency (preserve thread order)

Impact: Optimized for different data types. Right consistency model for each use case.



Strong consistency guarantees that all nodes see the same data immediately after a write completes.

Strong consistency write flow: Node 1 replicates to Nodes 2 and 3, waits for both ACKs, then confirms so any read sees 100 USD

Key Characteristic: The write operation blocks until all replicas confirm. Only then does the client get a success response.

Transferring 50 USD between accounts: strong consistency locks both accounts, eventual consistency updates A and queues B asynchronously
AspectStrong Consistency
Data AccuracyAlways correct, no stale reads
Write LatencyHigher (waits for all replicas)
AvailabilityLower (if one node is down, writes may fail)
ComplexityHigher (need coordination, locks)
Use CasesFinancial systems, inventory, critical state

Eventual consistency allows temporary differences between nodes, but guarantees all nodes will eventually converge to the same state.

Eventual consistency write flow: leader returns success immediately, Nodes 2 and 3 show stale likes until async replication converges

Key Characteristic: The write returns immediately after updating the leader. Replication happens asynchronously in the background.

Social media like: the count updates instantly for the user while background sync replicates it to other data centers
AspectEventual Consistency
Data Accuracy⚠️ Temporary inconsistencies possible
Write LatencyLower (returns immediately)
AvailabilityHigher (can write even if some nodes down)
ComplexityLower (no coordination needed)
Use CasesSocial media, analytics, non-critical data

Causal consistency preserves cause-and-effect relationships. If event A causes event B, all nodes that see B must have already seen A.

Out-of-order problem where a node shows a reply before its original post, solved by causal consistency preserving logical order

Causal consistency uses vector clocks or logical timestamps to track dependencies:

Causal consistency with vector clocks: a post [1,0,0] causes a reply [1,1,0], and both nodes deliver the reply only after the post

Key Characteristic: Events are delivered in causal order, even if they arrive out of order.

Chat example of causal consistency: Bob's reply to Alice depends on her message, so every node shows Alice's message first
AspectCausal Consistency
Data AccuracyPreserves logical relationships
Write LatencyLower than strong (no global coordination)
AvailabilityHigher than strong consistency
Complexity⚠️ Medium (need dependency tracking)
Use CasesChat, comments, collaborative editing

Decision tree for choosing a consistency model: strong for money and inventory, eventual for likes and views, causal for chat threads
Use CaseConsistency ModelWhy
Bank balanceStrongCan’t have incorrect balances
Inventory countStrongCan’t oversell products
Social media likesEventualSpeed > exact count
View countsEventualApproximate is fine
Chat messagesCausalNeed logical order
Comment threadsCausalReplies must follow posts
User profilesEventualCan tolerate slight delays

How consistency models affect your class design:

When you need strong consistency, use synchronization primitives:

💡 Tip: Click dropdown to switch between languages
Strong Consistency with Locks
from threading import Lock
class Account:
def __init__(self, balance):
self._balance = balance
self._lock = Lock() # Ensures atomic operations
def transfer(self, amount, to_account):
# Lock both accounts to prevent race conditions
with self._lock:
with to_account._lock:
if self._balance >= amount:
self._balance -= amount
to_account._balance += amount
return True
return False

Eventual Consistency → Use Version Numbers

Section titled “Eventual Consistency → Use Version Numbers”

For eventual consistency, track versions to detect conflicts:

💡 Tip: Click dropdown to switch between languages
Eventual Consistency with Versions
class Document:
def __init__(self, content):
self.content = content
self.version = 0 # Track version for conflict detection
def update(self, new_content, client_version):
if client_version != self.version:
# Conflict detected - need merge strategy
raise ConflictError("Version mismatch")
self.content = new_content
self.version += 1
return self.version

For causal consistency, maintain dependency graphs:

Causal Consistency with Dependencies
from typing import List, Set
class Event:
def __init__(self, data, dependencies: List[int]):
self.data = data
self.dependencies = set(dependencies) # Events this depends on
self.id = None # Assigned by system
class EventStore:
def __init__(self):
self.events = {} # id -> Event
self.seen = set() # Events this node has seen
def can_deliver(self, event: Event) -> bool:
# Can only deliver if all dependencies are seen
return event.dependencies.issubset(self.seen)
def deliver(self, event: Event):
if self.can_deliver(event):
self.seen.add(event.id)
# Process event...


Now that you understand consistency models, let’s explore the fundamental theorem that governs these trade-offs:

Next up: CAP Theorem Deep Dive — Learn why you can’t have everything: Consistency, Availability, and Partition tolerance.