Consistency models
Linearizable, sequential, causal, session guarantees and eventual: what each forbids, how to spot a violation, and how to pick the weakest one that is safe.
30 min9 steps
By the end you can
- Order the common consistency models by strength and say what each one forbids
- Identify which guarantee a concrete history of reads and writes violates
- Choose the weakest model that meets a product requirement, and implement session guarantees with log positions
- Estimate the chance a read misses a recent write when read and write sets need not overlap
A consistency model is a contract
The ladder of models
Linearizable
- One order, matches real time
Sequential
- One agreed order
- Keeps each client's order
- Ignores real time
Causal
- Cause before effect
- Concurrent writes may differ
Eventual
- Converge if writes stop
- Nothing in between
Order these models from strongest (allows the fewest histories) to weakest.
- 1Causal
- 2Eventual
- 3Sequential
- 4Linearizable
Sequential is not linearizable
Session guarantees, and how to build one
Read-your-writes
- See own earlier writes
Monotonic reads
- Never see older than before
Monotonic writes
- Your writes apply in order
Writes-follow-reads
- Write after what you read
Loading question…
Spot the violation
Causal consistency
How stale is eventual?
R + W > N
overlap
read hits a fresh replica
R + W <= N
can miss
read lands on unwritten replicas
Read repair
heals
stale replica catches up
Select read repair, then compare quorum overlap with sloppy quorum and hinted handoff in Script.
Loading question…
Choose the weakest safe model
Linearizable
- Uniqueness, locks
- Leader election
- Account balances
Session / causal
- My changes must show up
- Replies after posts
Eventual
- Feeds, counters
- Analytics reads
Check your mastery
Session wait
token vs replica
wait if replica is behind
Stale read
distinct picks
count replica choices
Score 80% or more. Next: clocks.
Mastery check
4 questions on fresh variants. One attempt each, no time limit. Score 80% or more to master the lesson.
Answer this step to continue.