From Linearizability to Eventual Consistency

Linearizability, sequential consistency, causal consistency, eventual consistency — definitions, examples, and which databases approximate which.

4/5Overview: 30m

Why definitions matter

"Strong consistency" is ambiguous until you specify what clients can observe. Interviewers want precise terms and trade-offs, not buzzwords.

The spectrum (strongest → weakest)

Linearizability

Every operation appears to take effect atomically at some point between its start and end. Strongest single-object guarantee; expensive (often needs consensus or single leader).

Interview example: After write(x=1) completes, every subsequent read(x) returns 1.

Sequential consistency

All operations appear in some total order consistent with each client's program order, but that order need not respect real-time (no simultaneous wall-clock constraint).

Causal consistency

If operation A causally affects B (same session, or read-your-write chain), everyone sees A before B. Concurrent writes may be seen in different orders.

Vector clocks detect causality (Topic 5).

Eventual consistency

If writes stop, all replicas converge to the same value. No bound on how stale a read may be during churn.

Dynamo, Cassandra, and many caches operate here by default for some paths.

Comparison table (memorize)

ModelStale reads?Ordering across clients?Typical cost
LinearizableNoTotal orderHigh (coordination)
SequentialMaybe vs real-timeTotal orderHigh
CausalBounded by causalityPer-causal-chainMedium
EventualYesNone guaranteedLow

What databases actually provide

  • etcd / ZooKeeper / Consul — linearizable reads/writes on the coordination path
  • PostgreSQL primary — linearizable on the leader (single writer)
  • Cassandra — tunable per query (ONE vs QUORUM vs ALL)
  • S3 — read-after-write consistency for new objects (evolved over time); list operations historically eventual

Name the operation, not just the product.

Jepsen awareness

Kyle Kingsbury's Jepsen tests real databases under partition and proves which claims hold. You don't need to memorize every test — know that claimed consistency ≠ observed consistency without verification.

Further Reading

Hands-On Tasks (Optional)

Low-setup exercises — browser visualizers, paper drills, or optional Docker. No autograding; the goal is interview fluency.

  • Draw a linearizability violation

    Two clients, one register, three operations (write A, write B, read). Draw a timeline where a client sees B then A without a linearizable ordering. Explain what the system promised instead.

    15m