Skip to content

Eventual Consistency

If no new updates are made to a piece of data, all nodes will eventually converge to the same value — given enough time.

Consistency Models (Spectrum)

ModelGuaranteePerformance
Strong ConsistencyAll reads see latest write immediatelySlower
Read Your WritesYou always see your own writesMedium
Monotonic ReadNever see older data than beforeMedium
Causal ConsistencyCausally related ops seen in orderMedium-fast
Eventual ConsistencyNodes converge eventuallyFastest

How It Works Internally — Cassandra Example

Step 1: Write balance = 800 → Node 1 (acknowledged)
Step 2: Node 1 asynchronously syncs to Node 2, Node 3
Step 3: Read from Node 2 immediately → might see 500 (not synced yet)
Step 4: Read from Node 2 after sync → sees 800

Window of inconsistency = milliseconds usually

Conflict Resolution Strategies

  • Last Write Wins (LWW): Highest timestamp wins. Simple but can lose data. Used by Cassandra default.
  • Vector Clocks: Track causality between writes. More accurate but complex. Used by DynamoDB, Riak.
  • CRDT (Conflict-free Replicated Data Types): Data structures that auto-merge. Counter: add all increments. Set: union of all sets. Used by Redis, Google Docs.
  • Application-level Resolution: DB surfaces the conflict, application decides how to merge. Used by Amazon Dynamo.

When Acceptable vs Not Acceptable

Acceptable (AP)Not Acceptable (CP needed)
Social media likes/viewsBank balance
DNS propagationFlight seat booking
Product catalogStock trading
User profile updatesAuthentication tokens
Shopping cart (Amazon)Financial transactions