Consistency Models
Start here
Consistency Models is a chapter of the System Design Masterclass course.
- 1.Data Compression18 min · the opening is free to read
- 2.Linearizability25 min · the opening is free to read
- 3.Causal Consistency20 min · the opening is free to read
770 lessons · 18 free to read
₹1,111 in India · $25 elsewhere, once
Get System DesignYou own this course
Two people split a bill. One taps "pay," sees the balance drop, then refreshes and sees the old balance again. Money looks like it moved and then un-moved. Nothing was actually lost, but the system showed two truths a second apart, and now a customer is filing a support ticket. That gap between "what one node thinks is true" and "what another node shows" is the entire subject of consistency models. The moment your data lives on more than one machine, you have to decide exactly which version of reality a reader is allowed to see.
A consistency model is the contract your storage layer makes about the order and visibility of reads and writes. Pick a strong model and every reader sees a single, agreed-upon history, but you pay in latency and availability. Pick a weak model and you get speed and the ability to keep serving during a network partition, but you accept that two readers can briefly disagree. This category walks the full ladder, from the strongest guarantee (linearizability) down through sequential, causal, and the session guarantees, then into the database-transaction side (snapshot isolation, serializability) and the conflict-free approaches (CRDTs, operational transformation) that let collaborative apps merge edits without a coordinator. It also covers the durability machinery that makes any of these guarantees survivable: write-ahead logging, checkpointing, snapshotting, and point-in-time recovery.
21 lessons in this topic · start with any of them
This page is the free part.
The course goes deeper on Consistency Models
₹1,111 in India$25 everywhere elseonce, for the whole course
The System Design course covers Consistency Models across a run of lessons, not one page. These 4 alone are about 88 minutes of step-by-step reading, every one with code you run in the browser, all with a quiz.
- Data Compression
Reduce data size to save storage and bandwidth, lossless vs lossy, and when each makes sense.
- Memory Management
How systems allocate, use, and reclaim memory, the difference between systems that scale and systems that crash.
- Thread Pooling
Reuse threads instead of creating them, the pattern that makes web servers handle thousands of concurrent connections.
- Garbage Collection
Automatic memory reclamation, how GC algorithms work and why they cause latency spikes in distributed systems.
all part of
System Design Masterclass
770 lessons · about 287 hours · 18 free to read
₹1,111in India, by UPI
$25everywhere else, by PayPal
It is really nice and good Please join the course
You own this course
Continue with Data Compressionpay once,
yours for life
What a Consistency Model Actually Promises
A consistency model is a precise statement about what a reader is allowed to observe given the writes that have happened. It is not about whether data is correct. It is about ordering and visibility. The strongest model, linearizability, says every operation appears to take effect at a single instant between its start and finish, so once any reader sees a new value, no reader can ever see the old one again. The system behaves as if there were one copy of the data and one global clock, even though there are many copies spread across machines.
Sequential consistency relaxes the global-clock part. All operations still appear in some single total order that every process agrees on, and each process's own operations keep their program order, but that order does not have to match real wall-clock time. Causal consistency relaxes further: it only guarantees that operations which are causally related (a reply must come after the message it answers) are seen in the right order everywhere. Unrelated operations can be seen in different orders by different readers, which is usually fine and much cheaper to provide.
Below those sit the session guarantees, which scope the promise to a single user's session rather than the whole system. Read-your-writes means you always see your own latest update. Monotonic reads means time never goes backward for you, so you will not see a value disappear after you have already seen it. Monotonic writes means your own writes are applied in the order you issued them. These are the guarantees users actually notice, and they are often the practical sweet spot.
Consistency in Databases: Isolation and Serializability
Distributed-systems consistency and database isolation describe the same problem from two angles. Where consistency models talk about replicas, transaction isolation talks about concurrent transactions touching shared rows. Serializability is the gold standard: the result of running transactions concurrently is identical to some order in which they ran one at a time. No lost updates, no anomalies, no surprises. It is the transactional cousin of linearizability and it is the easiest model to reason about, which is why it is worth the cost when money or inventory is involved.
Snapshot isolation is the model most production databases actually default to, and it is the one most engineers run without realizing it. Each transaction reads from a consistent snapshot taken at its start, so reads never block writes and writes never block reads. It eliminates most anomalies but allows write skew, where two transactions each read a shared state, each decide their write is safe, and together violate an invariant that neither broke alone. Knowing that snapshot isolation is not serializable, and knowing exactly which anomaly slips through, is the difference between a system that quietly corrupts data under load and one that does not.
Underneath all of these guarantees is durability, and durability is its own set of lessons here. Write-ahead logging records the intent to change data before the data itself is touched, so a crash mid-write can be replayed or rolled back cleanly. Checkpointing and snapshotting bound how much of that log has to be replayed after a restart. Point-in-time recovery uses the log plus a base snapshot to rebuild state as it existed at any chosen moment, which is what turns an accidental mass-delete into a recoverable incident rather than a resume-updating event.
Choosing a Model and Living With the Trade-Off
The honest framing is the CAP and PACELC tension: when the network splits, you choose between staying consistent and staying available, and even when the network is healthy you trade latency against consistency. Strong models like linearizability require coordination on every operation, which means cross-node round trips, higher tail latency, and an inability to serve writes when a quorum cannot be reached. Weak models skip the coordination, answer locally, and stay up through partitions, but hand you the job of resolving the disagreements they allow.
The right answer is per-feature, not per-system. A bank ledger or a seat-booking flow wants serializability or linearizability, because showing two truths there is a financial bug. A social feed, a like counter, or a presence indicator is perfectly happy with causal or eventual consistency, because a reader seeing a slightly stale count costs nothing and the latency savings are large. Most real products mix both: a strong core for the parts that move money or enforce uniqueness, and a fast eventually-consistent layer for everything else.
When you accept weak consistency, you need a strategy for the conflicts it produces, which is where the last cluster of lessons lives. Conflict resolution covers the policies: last-write-wins is simple but silently drops data, while smarter merges preserve intent. CRDTs (conflict-free replicated data types) are data structures whose merge operation is mathematically guaranteed to converge no matter the order updates arrive, which is how shopping carts and counters stay correct without a coordinator. Operational transformation solves the same merge problem for ordered text, transforming concurrent edits against each other so two people typing in the same paragraph end up with the same document.
How Real Systems Apply These Ideas
Google Spanner is the headline example of buying strong consistency at scale. It uses synchronized atomic clocks (the TrueTime API) to give external, linearizable transactions across data centers, which is why Google runs critical systems on a database that behaves like a single machine spanning continents. The price is that every commit waits out a small clock-uncertainty window. Amazon's DynamoDB takes the opposite stance by default, offering eventually consistent reads for speed and cost, with strongly consistent reads available as an explicit, more expensive option, so teams choose the guarantee per query.
Collaborative editors made these models visible to everyone. Google Docs is built on operational transformation so dozens of people can type at once and converge on the same document. Figma and many newer tools lean on CRDTs for the same reason, since CRDTs avoid the central transformation server that OT typically needs. Apple's Notes and offline-first mobile apps use CRDT-style merging so edits made on a plane reconcile cleanly when the device reconnects.
On the durability side, every serious database you have used runs the patterns in this category. PostgreSQL's write-ahead log is the source of truth for crash recovery and for streaming replication to standbys. Its base backups plus archived WAL are exactly what point-in-time recovery reads to rewind a database to the second before a bad migration. Redis offers both snapshotting (periodic point-in-time dumps) and an append-only log, letting operators trade durability against write throughput. These are not exotic features. They are the reason your data is still there after the process that wrote it crashed.
All 21 lessons in Consistency Models
- 01Data Compression
- 02Memory Management
- 03Thread Pooling
- 04Garbage Collection
- 05Data Deduplication
- 06Checkpointing
- 07Snapshotting
- 08Write-Ahead Logging
- 09Point-in-Time Recovery
- 10Data Consistency Models
- 11Monotonic Reads
- 12Monotonic Writes
- 13Read-Your-Writes
- 14Causal Consistency
- 15Sequential Consistency
- 16Snapshot Isolation
- 17Serializability
- 18Linearizability
- 19CRDTs
- 20Operational Transformation
- 21Conflict Resolution
Frequently asked questions
Learn Consistency Models the interactive way
All 21 lessons with step by step diagrams, runnable code, and quizzes, plus the rest of the 770 lessons in the course. One payment, lifetime access, no subscription.
course 1
System Design Masterclass
From absolute beginner to principal engineer, drawn step by step.
- 770 interactive lessons
- Step-by-step system design diagrams
- Live code editors
- Quizzes with instant feedback
- Progress tracking and streaks
- Lifetime access and all future lessons
What buyers of this course say
It is easy and good
It is really nice and good Please join the course
The concepts were explained in a clear and structured way, with practical examples that made even complex system design topics easier to understand. I especially liked the focus on real-world architecture, scalability, trade-offs. The content was well designed, engaging, and highly useful for anyone looking to strengthen their system design skills. Highly recommended for software engineers preparing for system design interviews or wanting to build a stronger foundation in designing scalable systems.
Outstanding all-in-one source of knowledge, especially excellent practice
Ive started this course by accident - LLM advised me this site. When I passed few free lessons, I had no doubt - this course should be bought. And I did it with special pleasent price and it was best decision of the month. Content is great, interesting to read and with a lot of practial cases (what makes it different from other souces and books) I hope to teach all the lessons, that will be my supergoal. Glad that I found this resource and speacial Thank You to Roni Das - Great Job!