Skip to main content
PreparationZone Logo
PrepZone

Consistency Models (Strong to Eventual)

Read-your-writes, monotonic reads, and when ShardPay's balance API can return stale data.

Pass checkpoint below

Read these first

Why this matters

  • Wrong consistency assumptions cause double-spend, ghost reads, and "I transferred but balance didn't change" support tickets.
  • API contracts should name the consistency level — not bury it in implementation details.
  • ShardPay uses different models per endpoint: linearizable commits, read-your-writes for sessions, eventual for analytics.
  • Interviewers ask you to pick a model for a scenario and justify the latency/availability cost.
LinearizableStrongest — single copy illusion
SequentialTotal order on all ops
CausalPreserves cause-effect
EventualConverges over time
Stronger guarantees cost latency and availability.

Models from strong to eventual

Transfer commit on ShardPay's ledger is linearizable: once the API returns 201 Created, any subsequent linearizable read on that account sees the debit. The merchant dashboard polls a replica with read-your-writes via session token. The finance team's nightly rollup reads from an analytics warehouse that may lag by minutes — eventual consistency with a documented asOf watermark.

Choosing the wrong model for an endpoint is a design bug, not a performance optimization gone wrong.

Spectrum overview

  • Linearizable (strong) — Operations appear to execute atomically in real-time order. ShardPay's POST /transfers commit point is linearizable: two concurrent transfers on the same account serialize as if one finished before the other started.
  • Sequential consistency — All nodes agree on the same order of operations, but that order may not match real-time. ShardPay's internal audit log stream across regions is sequentially consistent — all consumers see transfers in the same order, though timestamps may not match wall clocks.
  • Causal consistency — If operation A causally precedes B (B reads A's write), every node sees A before B. ShardPay's comment thread on a disputed charge respects causality: replies never appear before the parent note, even on lagging replicas.
  • Read-your-writes — A session always sees its own prior writes. After a merchant transfers funds, their dashboard session token routes reads to a replica that has applied that write — without always hitting the leader.
  • Monotonic reads — A session never sees time go backward. ShardPay's transaction list API never shows a newer page followed by an older one when paginating with a session cursor.
  • Eventual consistency — Replicas converge if writes stop; no bound on staleness during churn. ShardPay's global "total volume processed" counter on the marketing site is eventual — off by 0.1% for an hour is acceptable.

The rest of this guide is part of Pro

Free covers every fresher guide in full. Pro unlocks Senior, Staff and Architect guides across every track.

Still to come · 2 sections

  • Matching models to ShardPay endpoints
  • Weaker models still need contracts

Test yourself

Answer these before moving on — recall is what makes it stick.