CONCEPT SHEET · Concepts

Consistency Models

One-liner: A consistency model is the contract about which writes a read may observe; stronger models cost latency and availability.

ArticleConcepts© Arthur Bernier Jr556 words1 code block

Say this#

How it works#

TEXT
strong (linearizable)   ^  sequential   |  causal   |  session guarantees: read-your-writes, monotonic reads/writes   v  eventual

Quorum reads/writes (Dynamo, Cassandra, Riak):

  1. Write to N replicas, wait for W acks.
  2. Read from R replicas, return the newest version (by timestamp/vector clock).
  3. If R + W > N, at least one read replica has the latest write → strong-ish (not linearizable under failure/sloppy quorum).
  4. Common settings: N=3, W=2, R=2 (balanced); W=3,R=1 (read-heavy); W=1,R=3 (write-heavy).

Session guarantees in practice: route a user's reads to the leader for N seconds after their write, or carry a version/LSN token the replica must have caught up to.

Trade-offs#

ChoiceProCon
LinearizableSimple reasoning; safe for locks, uniqueness, balancesNeeds consensus or single leader; cross-region latency; unavailable in minority partition
CausalPreserves "reply after post" ordering, available under partitionMetadata (vector clocks) overhead; rarely offered natively (MongoDB causal sessions, Cosmos)
EventualLowest latency, highest availabilityStale reads, lost-update risk without conflict resolution
Read-your-writesCheap fix for the most visible anomalyRequires sticky routing or version tokens
R+W>N quorumTunable per requestLatency = slowest of W/R nodes; not truly linearizable

Numbers#

  • N=3, R=2, W=2 is the canonical Dynamo-style default.
  • DynamoDB: eventually consistent read costs half a strongly consistent read (0.5 vs 1 RCU per 4 KB).
  • Typical async replication lag: milliseconds in-region, hundreds of ms to seconds cross-region or under load.

In the interview#

See also