Consistency Models: Strong, Eventual and Causal

Consistency models explained: linearizability, sequential, causal, read-your-writes and eventual consistency, with examples of where each fits.

Intermediate 4 min read · Updated

A consistency model is a contract between a data store and its users about what reads can return when data is replicated and updated concurrently. Stronger models are easier to program against but cost latency and availability; weaker models are faster and more available but push complexity into the application.

From strongest to weakest

ModelGuaranteeTypical cost
Linearizable (strong)Every operation appears to happen at a single instant between its start and end; reads see the latest completed write, globallyCoordination (a leader or quorum) on every operation; unavailable on the minority side of a partition
SequentialAll clients see all operations in the same order, consistent with each client's own order, but not necessarily real timeStill needs agreement on a total order
CausalOperations that are causally related (a reply after the post it answers) are seen in that order by everyone; unrelated ones may differTracking dependencies (e.g. vector clocks); available during partitions
Read-your-writesA client always sees its own earlier writesSession stickiness or version tokens
Monotonic readsA client never sees data go back in timeStick a session to one replica, or track a version
EventualIf writes stop, all replicas eventually convergeCheapest; stale and out-of-order reads are possible

What goes wrong with weak consistency

Imagine asynchronous replication from a primary to read replicas, with a lag of a few hundred milliseconds:

UserPrimaryReplicaUPDATE name = 'Asha'OKreplicate (lagging…)GET profilename = 'A. Kumar' (stale!)replica catches up 300 ms later
Without read-your-writes, a user can update their profile and immediately see the old version because the read hit a lagging replica.

Other anomalies under eventual consistency:

  • Non-monotonic reads: refreshing a page shows a comment, then on the next refresh it disappears, because the second read hit a staler replica.
  • Causality violations: you see a reply before the message it replies to.
  • Lost updates: two concurrent writes to different replicas, and one silently overwrites the other (last-write-wins).

Worked example: who sees what, right after a write

The author updates a value from v1 to v2 at t = 0, and the replica needs 3 ticks to catch up. The levels differ only in what reads return during those 3 ticks:

LevelAuthor reads (t = 1)Another user reads (t = 1)After the replica syncs (t ≥ 3)
Strongv2v2 (reads go to the leader or wait for replicas)v2 / v2
Read-your-writesv2 (the author's reads are routed to fresh data)v1 (may be stale)v2 / v2
Eventualv1 (even the author may see stale data)v1v2 / v2

Stronger levels send reads to the leader or wait for replicas to confirm, which costs latency and availability; weaker levels read the nearest replica and may be stale. Pick the weakest model the feature tolerates: read-your-writes is often the sweet spot for profile edits and posts.

Practical techniques

  • Read your own writes: after a user writes, route their reads to the primary for a short window, or return a version (an LSN or timestamp) with the write and have replicas wait until they've caught up to it.
  • Monotonic reads: pin a user's session to one replica (by hashing the user id).
  • Quorums: with N replicas, writing to W and reading from R where R + W > N guarantees a read overlaps the latest write. See replication.
  • Conflict handling for concurrent writes: last-write-wins (simple, loses data), version vectors that surface conflicts to the app, or CRDTs, data types like counters and sets that merge automatically. See clocks and ordering.

Choosing a model per feature

DataModel that fitsWhy
Account balance, inventory count, unique usernamesLinearizableTwo people must not both get the last seat or the same username
A user editing their own profile or settingsRead-your-writesSeeing your own change disappear looks like a bug
Comments and replies, chat messagesCausalReplies must not appear before what they answer
Like counts, view counts, recommendationsEventualBeing a few seconds behind is invisible to users
Search index, analytics dashboardsEventual, with a known lagUpdated asynchronously from the source of truth

Strong consistency isn't free, but neither is weak consistency: every anomaly you allow becomes a bug someone has to reason about. Use strong consistency for invariants that matter, and weaker models where staleness is harmless.

Where it’s used

Google Spanner and CockroachDB

Offer externally consistent (linearizable) transactions across regions using consensus and carefully bounded clocks.

Amazon DynamoDB

Defaults to eventually consistent reads; a strongly consistent read option reads from the leader at higher cost.

Facebook TAO

The social graph cache is eventually consistent but provides read-after-write for a user's own actions within a region.

Collaborative editors

Google Docs-style editing relies on operational transforms or CRDTs so concurrent edits converge without coordination.

In an interview

  • Don't say "strongly consistent" or "eventually consistent" for the whole system; pick a model per kind of data and justify it.
  • Call out read-your-writes whenever you add read replicas or caches, and say how you'll provide it.
  • Use R + W > N when discussing quorum replication.
  • For concurrent writes, say how conflicts are resolved: last-write-wins, version vectors, or CRDTs.