Module 22 / 46 · Phase E — Distributed Reality · 45 min

Consistency
models.

"Eventually consistent" sounds like one thing. It's actually six. Between the rigorous mathematical guarantee of linearizability and the loose promise of eventual, there's a precise spectrum — and your database lives somewhere on it whether you've thought about it or not.

// What you'll know by the end

  • The 6-level consistency spectrum, precisely
  • Why "strongly consistent" means three different things
  • The session guarantees most apps actually want
  • Which model real databases give you (and at what price)
§ 01 — One word, six meanings

"Eventually."
What does that
even mean?

Open any distributed database's marketing page and you'll see one of two phrases: "strongly consistent" or "eventually consistent." Both are useless without qualification. Strongly consistent on every read? Only under load below some threshold? Only on the same replica? Eventually consistent within how long? A millisecond? A minute? "Whenever your network unpartitions"? Every one of these is a real product. Every one ships with the same English-language summary. The conversation can't even begin until you know which precise model is on the table.

// "EVENTUALLY" — REAL INTERPRETATIONS FROM REAL VENDOR DOCS
~10ms
"Best-effort eventual." Replication is async but pipelined; under healthy network conditions, replicas converge in tens of milliseconds. Marketed as "strong" by some vendors. Behavior degrades silently under load.
seconds
Cross-region async replication. Primary commits locally; secondaries catch up over the long-haul link. A read from the wrong region returns a value that's seconds old. Common in region-failover setups.
"on heal"
AP database during partition. Diverged for the duration of the partition; converges when the network reconnects. Could be milliseconds. Could be days. The system makes no promise about the gap.
never
Without conflict resolution, diverged values can persist forever. Some systems let you read both and require the application to merge. "Eventual" only happens if your code makes it happen.

The fix for this fuzziness is the same as every other fuzziness in distributed systems: use the precise names. The consistency-model literature has been precise about this since the 1970s; the field of practice took a while to catch up. By the end of this module, when you see "strongly consistent" in a database's docs, your next instinct will be "which one — linearizable, sequential, or just primary-only-reads?" The answers are very different.

"Eventually" is not a guarantee. It's an aspiration. Don't confuse them.

This module climbs the consistency ladder rung by rung — from linearizability at the top (every read sees the latest write, no exceptions) down through sequential, causal, the four session guarantees, and finally to eventual. The lab in §04 lets you take the same scenario of writes and reads and replay it under each model, watching anomalies appear and vanish as you adjust the dial. The point isn't to memorize definitions; it's to feel where each model breaks.

§ 02 — The spectrum

Six rungs,
strongest to weakest.

The consistency ladder is well-defined and well-named — the names just don't appear in product brochures, so most engineers haven't met them. Here's the full ladder, top to bottom. Each rung permits everything below it; each rung forbids the anomalies listed in the rungs above it. The higher you climb, the more coordination you need — and the more latency you pay.

// THE LADDER · STRONGEST AT TOP

Linearizable Sequential Causal Read-your-writes Monotonic Eventual global lock total order happens-before per session per session none ← STRONGER WEAKER → slowest reads fastest reads
iLinearizable
Every operation appears to execute atomically at some real-time instant between its invocation and response. After a successful write, every read on every replica returns that value. Strongest model. The "single-machine" illusion preserved.
// cost~10ms+cross-replica round-trip
iiSequential
A single global order of operations exists that's consistent with each process's local order. Weaker than linearizable: doesn't require the order to match real wall-clock time. If A's write appears to happen after B's read in wall-clock time, sequential may still order A before B.
// cost~5mspartial coordination
iiiCausal
Operations that are causally related (one happened after seeing another) are observed in the same order on every replica. Operations with no causal relationship can be observed in different orders. Captures intent without paying for total ordering.
// cost~2mstrack dependencies
ivRead-Your-Writes
A client always sees their own writes on subsequent reads. Per-session guarantee — doesn't constrain what other clients see. "I posted a comment, I should see it when I refresh." The lightest model that doesn't feel broken to users.
// cost~1msroute to primary
vMonotonic Reads
A client never reads a value older than one they've already seen. Time may stand still; it may not run backward. Avoids the bewildering experience of "I saw this update, now it's gone."
// cost~1mstrack version
viEventual
If no new writes happen, all replicas eventually converge. No bounds on staleness, no ordering guarantees, no protection from anomalies. The weakest meaningful model — basically: "give it enough time and it'll be fine."
// costfreelocal read only

Two things to internalize. First, this is a strict hierarchy: linearizable implies sequential implies causal implies read-your-writes (and so on). If your system gives you linearizability, you have all the others for free. If it gives you eventual consistency, you have none of the others — and might be surprised by every anomaly above. Second, the cost grows steeply as you climb. Linearizability requires consensus protocols (M.24 territory); eventual requires nothing but background replication.

Each rung of the ladder forbids more anomalies — and costs more in coordination.

The middle rungs — causal and the session guarantees — are where most well-designed systems actually live. They're strong enough to feel correct to users, weak enough to scale. The mistake most teams make isn't picking the wrong rung; it's not knowing they made a pick. Once you can name the level you're on, you can defend or change it on purpose.

§ 03 — Session guarantees

Four small
promises, per user.

Linearizable is the gold standard but expensive. Eventual is cheap but baffling. The middle ground — and the model most user-facing apps actually need — is the family of session guarantees. These promise consistency from a single user's perspective, while still allowing other clients to see different things. They're cheap to implement (often: stick a client's reads to one replica, track its highest-seen version) but eliminate the failures that feel most broken in production. Named in the famous Bayou paper (1994), they're a 30-year-old toolkit barely taught in modern bootcamps.

// THE FOUR SESSION GUARANTEES · CLIENT-CENTRIC CONSISTENCY

// SG-1
Read-Your-Writes
"After I write a value, I see that value on subsequent reads."

The anomaly it prevents: "I just posted a comment but it's not on my page when I refresh." Solved by routing the client's reads to the primary (or a replica that has caught up to the client's last write timestamp).

// SG-2
Monotonic Reads
"If I've seen version N of an item, I never see a version older than N."

The anomaly it prevents: "I saw 10 likes on this post, refreshed, and now it shows 7." Solved by tagging each client read with the highest version it has seen and requiring future reads to be at least that fresh.

// SG-3
Monotonic Writes
"My writes are applied in the order I issued them."

The anomaly it prevents: "I changed my profile name to 'Jane', then to 'J. Doe'. Now it shows 'Jane' again." Solved by tagging writes within a session and serializing them — even across replicas.

// SG-4
Writes Follow Reads
"If I read value V, any subsequent write of mine is applied after V."

The anomaly it prevents: "I read a post, replied to it. Now my reply shows up before the post." Solved by tagging the read's version into subsequent writes from the same session.

These four composed together deliver an experience that feels strongly consistent to any individual user — even though the system is technically still eventually consistent globally. Two users on opposite sides of the world might see different versions of the world for a few seconds, but neither will see their own actions out of order. That property is what makes social media feel coherent at scale: your tweets, your likes, your comments all appear consistent to you, while the global feed converges asynchronously.

This is the cheapest way to make an eventually-consistent system feel correct. No consensus protocol, no synchronous replication, no expensive coordination — just track a few version numbers per session. Most production systems should reach for session guarantees first, and only climb higher (to causal or linearizable) when there's a specific operation that requires it.

§ 04 — Two-replica timeline · interactive lab

Watch anomalies
appear and vanish.

Below: four canonical anomaly scenarios. Pick one. Then toggle through the six consistency models. Operations that violate the chosen model glow red. Same exact sequence of events — the question is which model is strong enough to forbid the anomaly, and which is content to allow it. This is the lab where the spectrum becomes intuition.

CONSISTENCY.SIM // m.22 lab
// TWO-REPLICA TIMELINE · time flows left to right
MODEL · LINEARIZABLE
Linearizable
"Every read returns the most recent write, system-wide."
Loading...
// VERDICT
Loading...

Loading...

§ 05 — Picking the right rung

When to climb,
when to stay down.

Now you have the names. The next question is which one to pick for a given problem. The honest answer: most operations don't need linearizability. The honest design move: figure out the smallest set of operations that genuinely require strong guarantees, lift those to the appropriate rung, and leave the rest weakly consistent. Below: the rough mapping.

// WHICH MODEL DO YOU ACTUALLY NEED?

LINEARIZABLE
Money. Identity. Locks. Counters that must never lose increments. Anything where a stale read or lost write would cause real damage. Bank balance, unique constraint enforcement, "is this room booked?" These pay the latency cost because correctness is non-negotiable. Systems: etcd, ZooKeeper, Spanner.
CAUSAL
Conversations. Collaborative editing. Comment threads. Anywhere a reply must appear after the thing it replies to. Allows fast local writes while preserving "effect-after-cause" intuition. Systems: COPS, Eiger, some Cosmos DB modes.
SESSION (RYW + MR)
Most user-facing apps. Profile pages, posts, settings, dashboards. Don't need global ordering — just need each user to see a coherent view of their own actions. The sweet spot for cost vs feel. Systems: DynamoDB with session tokens, MongoDB causal sessions, most "eventually consistent" databases configured well.
EVENTUAL
Counters. Likes. View counts. Telemetry. Recommendation scores. Anywhere "approximately right" is fine and the absolute number doesn't matter. Cheapest by far. Defaults to "correct in the long run." Systems: Cassandra with low consistency levels, Redis with async replication, most caches.

Two practical points. First, a single application typically uses multiple models. The same product reads its inventory count with eventual consistency (it's fine if it's off by a few seconds) but writes order placement with linearizability (you must not double-sell the last item). Engineers who pick one model for the whole system are usually paying too much somewhere and too little somewhere else. Second, the database picks for you unless you say otherwise. DynamoDB defaults to eventual; you have to explicitly ask for strong. Postgres reads from the primary with linearizable semantics by default; you have to deliberately read from replicas to get the cheaper, weaker version. Know your defaults.

Most operations don't need linearizability. The skill is finding the few that do.
§ 06 — Eight words for the consistency conversation

Vocabulary,
for the ladder.

The terms that appear in every distributed database's documentation. Master these and the papers, the docs, the debugging conversations all open up.

Linearizability
/ˌlɪn.i.ɚ.aɪ.zəˈbɪl.ɪ.ti/
The strongest single-key consistency. Each operation appears to take effect atomically at some instant between its start and end. Sometimes called "atomic consistency" or (loosely) "strong consistency."
Sequential Consistency
/sɪˈkwen.ʃəl/
A total order of operations exists that's consistent with each process's program order. Weaker than linearizable — doesn't need to respect real-time. Defined by Lamport, 1979.
Causal Consistency
/ˈkɔː.zəl/
Operations linked by a "happens-before" relationship are seen in that order by every node. Concurrent operations (no causal link) can be seen in different orders by different nodes.
Happens-Before
/ˈhæp.ənz/
A relation between events: A happens-before B if (a) same process, A before B, or (b) A sends a message that B receives, or (c) transitivity. The basis for causal ordering.
Session Guarantee
/ˈseʃ.ən/
A consistency property scoped to a single client session, not the global system. Cheap to implement (track per-session state) but eliminates the most user-visible anomalies.
Replication Lag
/ˌrep.lɪˈkeɪ.ʃən læɡ/
The delay between when a write commits on the primary and when it's visible on a replica. Determines how stale a stale read can be. The variable that bites the moment you read off a replica.
Quorum Read
/ˈkwɔː.rəm riːd/
Reading from a majority of replicas and returning the newest value found. Provides linearizability if combined with quorum writes. Pattern used by Cassandra, DynamoDB, Riak.
Anomaly
/əˈnɒm.ə.li/
An observation that violates a consistency model. Examples: stale read, lost update, write skew, phantom read. Each consistency level defines which anomalies it forbids.
§ 07 — Knowledge check

Five questions.
Pick your rung.

Test the consistency-model intuition. Click an answer; explanation drops in instantly.

QUESTION 1 OF 5
Loading question...
Score: 0 / 5
5 / 5

Climbed.

Perfect. The consistency ladder is yours, and "eventual" no longer means one thing. Next: how distributed systems agree on order in the first place — Lamport clocks and the foundations of "happens-before."

§ 08 — The recap

Three ideas to
carry forward.

Consistency is a precise vocabulary, not a marketing word. These ideas show up in every system you'll touch.

i

Six rungs, not two

Linearizable, sequential, causal, RYW, monotonic reads, eventual. Each rung forbids more anomalies and costs more in coordination. Knowing the names is the entire fight.

ii

Session guarantees are underused

Most user-facing apps need RYW + monotonic reads, not full linearizability. Cheap to add, eliminates 80% of "this feels broken" anomalies. Reach for them first.

iii

One app, multiple models

Stronger guarantees only for the operations that truly need them. Money is linearizable; like counts are eventual. Pick per operation, not per system.

↓ UP NEXT

M.23 — Time, order,
and Lamport clocks.

You now know what consistency models guarantee. But how do distributed nodes agree on order when there's no shared clock? The "happens-before" relation, logical clocks, vector clocks — the mathematical foundations that make causal consistency possible.

Continue to Module 23 →