Consistency models
Linearizability, sequential, causal, read-your-writes and eventual consistency, and what users actually notice.
18 min readA ladder of guarantees
A consistency model is a promise about what reads can return given the writes that happened. Stronger promises are easier to program against and more expensive to provide.
- Linearizable (strong): the system behaves as if there were one copy, and every read sees the latest completed write
- Sequential: all clients see writes in the same order, but not necessarily in real-time order
- Causal: if write B depends on write A (a reply to a comment), everyone sees A before B
- Eventual: if writes stop, replicas converge; until then anything goes
Session guarantees users notice
Between strong and eventual sit cheap guarantees scoped to one user's session, and these prevent most visible bugs. Read-your-writes: after I post, I see my post. Monotonic reads: I never see a newer value and then an older one, which happens when consecutive reads hit followers with different lag. Consistent prefix: I never see an answer before its question. Most of these can be provided by sticky routing or by carrying a version token with the session, without coordinating the whole cluster.
Where you need linearizability
Some decisions are wrong if made on stale data: a uniqueness constraint such as one username per person, a lock or leader lease, the last seat on a flight, or an account balance before a withdrawal. These need a linearizable operation, typically a single-leader write with a conditional check, a compare-and-set, or a consensus-backed store. Everything else, such as like counts, view counters, feeds and recommendations, is usually fine with eventual consistency plus session guarantees.
Say it in the design
Name the consistency each data path needs and why, rather than claiming the whole system is strongly consistent. For example: inventory reservations are linearizable per SKU via a conditional update on the primary; product pages tolerate 5 seconds of staleness from cache. Reviewers, and the SystCode rubric, reward designs that spend strong consistency only where an invariant needs it. A design that makes everything linearizable usually pays for it in cross-replica latency on every write and in lower availability during failures, for no user-visible benefit on most paths.
Key takeaways
- Stronger consistency is easier to reason about and costs latency and availability
- Read-your-writes and monotonic reads fix most user-visible anomalies cheaply
- Use linearizable operations for invariants: uniqueness, locks, last-item inventory, balances
- State the consistency requirement per data path, not per system
Sign in to track lessons and earn badges.