Notesdistributed🌱 seedling
Eventual Consistency
Also: Eventually Consistent · Convergent Replication
If writes stop, all replicas eventually return the same value. A liveness promise only: it says nothing about what reads return before then, or how long "eventually" is.
Why it exists
It lets every replica accept reads and writes independently, so the system stays up through partitions and answers with local latency. Most reads tolerate a little staleness.
How it works
- Replicas apply writes in whatever order they arrive and propagate them in the background.
- Divergent replicas need a conflict rule: Last Write Wins, CRDTs or application merges.
- Background repair closes gaps: Read Repair on reads, Anti-Entropy (e.g. Merkle-tree comparison) between replicas.
- Session guarantees (Read-Your-Writes Consistency, Monotonic Reads) can be layered on top for one client.
Trade-offs
| Gains | Costs |
|---|---|
| totally available; local latency | stale and reordered reads |
| no coordination on the write path | conflicts must be merged, sometimes losing writes |
| scales across regions | "eventually" is unbounded; lag spikes under load |
In practice
- Facebook TAO (2015 measurement): about 0.0004% of reads to vertices would have returned a different result under linearizability.
- Amazon S3 was eventually consistent for some operations until December 2020, when every GET, PUT and LIST became strongly consistent at no extra cost.
- DynamoDB: eventually consistent reads can be served by any replica and cost half a strongly consistent read.
Pitfalls
- Treating "eventually" as "soon". Monitor lag; it can stretch to minutes.
- Using last write wins with wall clocks: skew silently discards writes.
Connections
Recall
These cards are also in your review deck, scheduled with spaced repetition.