Consistency vs Eventual Consistency
A consistency model is a promise about what a read can return when data is replicated. Strong consistency (linearizability) promises that once a write is confirmed, every later read, on any replica, sees it: the system behaves like a single copy. Eventual consistency only promises that if writes stop, all replicas will eventually agree; until then, a read may return an older value.
The trade is simple: strong consistency needs replicas to coordinate on every operation, which costs latency and availability. Eventual consistency lets each replica answer on its own, which is fast and survives partitions, but pushes stale reads and conflicts onto the application. See CAP and PACELC for the theory.
Quorums: tuning between the two
Leaderless (Dynamo-style) databases such as Cassandra, ScyllaDB and Riak let you choose, per request, how many replicas must answer. With N replicas, a write waits for W acknowledgements and a read asks R replicas.
- Three replicas each hold version v1 of a shopping cart.
- A write of v2 with W = 2 succeeds once A and B confirm. The copy to C is dropped.
- A read with R = 1 happens to ask C and returns v1. Fast, available, and stale.
- A read with R = 2 must ask two replicas. Any two overlap with the two that took the write, so it sees v2 and returns the newest. That is the R + W > N rule.
- The coordinator notices C is behind and writes v2 back (read repair). Background anti-entropy does the same for data nobody reads. The replicas have eventually converged.
Quorums make stale reads much less likely, but on their own they are not full linearizability: sloppy quorums, concurrent writes and clock-based conflict resolution can still surprise you. Systems that need a hard guarantee use consensus (Raft, Paxos) instead.
The spectrum of consistency models
| Model | Promise | Example |
|---|---|---|
| Linearizable (strong) | Behaves like one copy; reads see the latest confirmed write | etcd, ZooKeeper writes, Spanner, DynamoDB strongly consistent reads |
| Sequential | Everyone sees operations in the same order, not necessarily real-time order | ZooKeeper reads |
| Causal | If B depends on A (a reply to a comment), nobody sees B without A | MongoDB causal sessions, many CRDT systems |
| Read-your-writes | You always see your own updates | Session guarantees, sticky routing to the leader |
| Monotonic reads | You never see time go backwards | Pinning a user to one replica |
| Eventual | Replicas converge if writes stop; no promise about when | DNS, Cassandra at ONE, async read replicas |
Stronger models are easier to program against and slower to run. Many systems mix them: strong for money and inventory, eventual for likes, view counts and recommendations.
When replicas disagree: resolving conflicts
Eventually consistent systems that accept writes on several replicas must merge concurrent updates:
- Last-write-wins (LWW): keep the value with the highest timestamp. Simple, but silently drops writes, and clock skew can make the “last” write the older one. See Clock.
- Version vectors: detect that two writes were concurrent and keep both versions (siblings) for the application to merge.
- CRDTs (conflict-free replicated data types): counters, sets and maps designed so that any merge order gives the same result. Used in Riak, Redis Enterprise active-active, and collaborative editors.
Real settings you will meet
- Amazon S3: strong read-after-write consistency for all objects since December 2020. Older “S3 is eventually consistent” advice is outdated.
- DynamoDB: eventually consistent reads by default;
ConsistentRead=truefor strong reads at twice the read cost (not available on global secondary indexes). - Cassandra: consistency level per query (
ONE,QUORUM,LOCAL_QUORUM,ALL). - PostgreSQL / MySQL read replicas: the primary is strong; async replicas are eventually consistent. See Replication.
- Data pipelines: a CDC stream, a search index or a cache fed from a database is an eventually consistent copy of it.
Common mistakes
- “Eventually” with no bound. Measure replication lag and set an alert; “eventually” in production should mean milliseconds or seconds.
- Reading your own write from a replica. Use leader reads or session tokens for read-after-write flows.
- Relying on LWW for data you cannot lose, such as counters or carts. Use CRDTs or conditional writes.
- Choosing one model for the whole system. Decide per entity and per query.
Learning Resources
Articles and papers
- Eventually Consistent: Werner Vogels, the classic introduction
- Consistency Models: Jepsen’s map of models and how they relate
- Amazon S3 Update: Strong Read-After-Write Consistency
- Eventual Consistency vs. Strong Eventual Consistency vs. Strong Consistency, Baeldung
Books
- Designing Data-Intensive Applications (2nd ed.), Martin Kleppmann and Chris Riccomini: chapters on replication and consistency