What Is Eventual Consistency - and When You Actually Need Strong Consistency Instead
Eventual consistency is a guarantee about when copies of your data agree: if you stop writing to a record, every replica of it will converge on the same value after some unbounded delay. It is not a guarantee that a read you issue right now returns the value you just wrote, and that gap is the whole subject of this page.
It exists because the moment your data lives on more than one machine, you have to choose what happens during the milliseconds - or minutes - while a write is still in flight. You can make every read wait for the replicas to coordinate, or you can let reads be fast and sometimes stale.
Eventual consistency is the second choice, made deliberately and written down. The useful question is never "is stale data acceptable" in the abstract. It is "which specific read in my system can tolerate being a few hundred milliseconds behind, and which one cannot."
| Concept | Eventual consistency |
|---|---|
| Where it sits | Data layer - a replication guarantee, sitting between your database and the reads your service issues |
| In one sentence | Replicas converge on the same value once writes stop, so reads are fast but may return a value that is slightly out of date. |
The 60-Second Answer
What it does: lets a write be accepted by one replica and spread to the others asynchronously, so reads never wait for a cross-replica agreement.
The problem it solves: reads and writes stay available and low-latency even when replicas are far apart or a replica is unreachable.
The cost it adds: a staleness window your application has to be correct in spite of - plus the need to resolve conflicting concurrent writes, because two replicas can both accept a write to the same key.
The decision rule: if a wrong read can be corrected a second later with no user harm and no money moved, eventual consistency is cheap. If a wrong read authorises something irreversible, it is not.
How It Actually Works
The mechanism, step by step
- 1. A write is acknowledged before every replica has it
- 2. The write propagates asynchronously in the background
- 3. A read can land on a replica that has not caught up
- 4. Concurrent writes to the same key produce conflicts
- 5. Quorum sizing moves you along the spectrum
- 6. Session guarantees make the staleness invisible to one user
- 7. "Eventually" has preconditions, and they can fail
1. A write is acknowledged before every replica has it
The acknowledgement is local, not global
Under a strongly consistent design, a write returns only after enough replicas have coordinated that no subsequent read can miss it. Under eventual consistency, a replica accepts the write, durably records it, and acknowledges it to the client - while the other replicas still hold the old value.
That is the entire trade in one sentence. You moved the cross-machine coordination off the write path, which is why the write is fast and why it still succeeds when a peer replica is down.
⚠️ In production — The acknowledgement no longer means "this is the truth everywhere". Teams get burned when a client treats a successful write as permission to immediately read the value back from a different connection, which may be routed to a different replica.
2. The write propagates asynchronously in the background
Replication log, gossip, or repair
After the ack, the system ships the change to the remaining replicas - typically by streaming a replication log to followers, or by peer-to-peer propagation plus a background anti-entropy process that compares replicas and repairs differences it finds.
These paths are deliberately decoupled from the client request. That is what makes the write latency independent of how far away the slowest replica is, which matters enormously once replicas span regions.
⚠️ In production — Replication lag is not a constant; it is a queue, and queues grow. A bulk import, an index rebuild, or a slow disk on one follower will stretch a normally-millisecond lag into minutes, and that is exactly when your stale reads become visible to users.
3. A read can land on a replica that has not caught up
The staleness window
Because any replica can serve reads, the value you get depends on which replica you hit and how far behind it is. The distance between "what has been written" and "what this replica knows" is the staleness window, and it is a distribution with a long tail, not a fixed number.
Worse, consecutive reads can move backwards in time: read one hits a caught-up replica, read two hits a lagging one, and a value that existed appears to vanish. That is a legal outcome under plain eventual consistency.
⚠️ In production — You cannot reason about this from averages. Instrument the actual per-replica lag and alert on the high percentiles, because the user who sees the anomaly is always in the tail, and they will report it as data loss rather than as lag.
4. Concurrent writes to the same key produce conflicts
Someone has to pick a winner
If two replicas can both accept writes, two clients can write the same key at the same time with neither write seeing the other. Convergence then requires a conflict resolution rule. The cheap one is last-write-wins by timestamp. The careful ones keep causal metadata - version vectors - so the system can detect that two writes were genuinely concurrent and hand both versions to the application, or use a data type that merges by construction.
# concurrent writes to the same cart, resolved by timestamp
write_a = {"cart": ["book"], "ts": 1000}
write_b = {"cart": ["lamp"], "ts": 1004}
# last-write-wins keeps write_b; "book" is silently dropped
# a set-union merge keeps both: ["book", "lamp"]
⚠️ In production — Last-write-wins is data loss with a polite name, and it depends on clocks you do not control. It is a reasonable choice for values that are wholly overwritten each time, like a cached profile blob; it is the wrong choice for anything accumulative, like a cart, a counter, or a set of permissions.
5. Quorum sizing moves you along the spectrum
Overlap the read set and the write set
Eventual and strong are endpoints, not a binary. If each key lives on N replicas, a write waits for W acks and a read gathers R responses, then making the read set and write set overlap forces every read to see at least one replica carrying the latest write.
N = 3 # replicas per key
W = 2 # replicas that must ack a write
R = 2 # replicas that must answer a read
# R + W > N -> the two sets must share a replica
This is a per-operation dial. You can run most reads at R = 1 for speed and raise R only for the handful of reads that must not be stale.
⚠️ In production — Overlapping quorums raise latency to the slowest replica in the quorum and reduce how many failures you can absorb before writes start rejecting. They also do not by themselves give you a total order across keys - that is a different and more expensive guarantee than freshness of a single key.
6. Session guarantees make the staleness invisible to one user
Read-your-writes and monotonic reads
Most user-visible weirdness comes from one person not seeing their own action. You can fix that specific case without making the whole system strongly consistent, by recording the replication position a user's write reached and requiring their later reads to be served from a replica at or past that position.
# pseudocode: pin this user's reads to their own write
pos = db.write(user_id, profile) # replication position of the write
session["read_floor"] = pos
db.read(user_id, min_position=session["read_floor"])
Read-your-writes and monotonic reads are per-session properties. They cost far less than global ordering and they remove the majority of "the data disappeared" reports.
⚠️ In production — Routing a user stickily to one replica is the lazy version of this, and it breaks the moment that replica is cycled during a deploy or the user switches networks. Carrying an explicit position token survives both.
7. "Eventually" has preconditions, and they can fail
Convergence is conditional, not automatic
Convergence assumes writes to the key stop long enough for propagation to finish and that replicas become mutually reachable again. A partition that lasts hours, a replica that has been down past the retention of the replication log, or a hot key under continuous write pressure can all leave replicas durably divergent.
That is why production systems run explicit repair: comparing replica contents in the background and reconciling, rather than trusting that propagation already happened.
⚠️ In production — The failure almost nobody plans for is a replica rejoining after being offline longer than the log retention window. It cannot catch up incrementally and needs a full re-sync, which is a capacity event - and until it finishes, that replica may be serving reads that are hours old unless you have fenced it off.
## Where You Meet It
- A social feed with like counts. The write path accepts likes at whatever rate they arrive and the count propagates behind it. If your count is briefly off by three, nobody notices and nothing is lost; forcing a coordinated write per like would put a global lock in front of your most frequent operation.
- A multi-region product catalogue. Editors write in one region, shoppers read in five. Reads are served locally so page latency is governed by the nearest replica, and a price edit becomes visible everywhere within seconds. The business accepts the window for descriptions and images - but checkout re-validates price against the authoritative store before charging.
- DNS. A record change propagates according to cached TTLs, so different resolvers legitimately return different answers at the same moment. The entire internet's name resolution runs on this model because the alternative - coordinating every resolver before any answer is given - would not work at that scale.
- A read-replica setup in front of a single-primary SQL database. Writes go to the primary, dashboards and search read from followers. The system is strongly consistent for writes and eventually consistent for reads, and the bug report that forces you to understand the difference is always a user updating a setting and then not seeing it on the next page load.
When You Actually Need It
- Your read volume is far higher than your write volume and you want to scale reads by adding replicas rather than by growing one machine.
- Readers are geographically distant from writers and the round-trip for cross-region coordination would dominate your request latency.
- You need writes to keep succeeding when a replica or an availability zone is unreachable, rather than returning errors until a quorum recovers.
- A stale read for the data in question is self-correcting: the user retries, the next poll fixes it, or the value is advisory rather than authoritative.
- Conflicts on a given key are either rare or structurally mergeable - append-only sets, counters, or last-value-overwritten caches - so resolution does not require human judgement.
When You Don't
- A single database can still hold your workload. If your dataset fits on one machine with headroom and your write volume is nowhere near its IO limit, use one primary and get strong consistency for free. Adopting multi-writer replication to prepare for scale you do not have buys you conflict resolution bugs years before it buys you throughput.
- The read authorises something irreversible. Balance checks before a transfer, inventory decrements on the last unit, coupon redemption, seat booking. Use a transactional write with the condition enforced at the authoritative store - a conditional update or
SELECT ... FOR UPDATE- so the check and the act are one operation. Reading a stale balance and then writing is a double-spend waiting to happen. - Uniqueness and other cross-record invariants. "Only one account per email" or "this schedule has no overlap" cannot be enforced by replicas that accept writes independently; both replicas will say yes. Enforce it with a unique constraint in a single authoritative store, or route all writes for that key space through one owner.
- The only symptom is a user not seeing their own change. Do not escalate the whole system to strong consistency for this. Add read-your-writes for that session, or just read the record you wrote back from the primary on that one code path.
- Your team cannot yet observe replication lag. Eventual consistency without lag metrics and divergence alerts is not a design, it is a class of intermittent bug that is extremely hard to reproduce. Build the observability first, or keep reads on the primary until you have it.
What People Get Wrong
"Eventual consistency means the data will be consistent in a few milliseconds."
The guarantee has no time bound at all. Milliseconds is the typical case on a healthy cluster; the bound you actually operate against is whatever your lag monitoring shows at the 99th percentile during your worst hour. If you need a number in a contract, you need to measure and enforce it yourself - the model does not supply one.
"It's a choice between eventual and strong, so pick one for the system."
Freshness is tunable per operation in most real stores, via quorum sizing, follower-versus-primary routing, or session tokens. Mature systems are mixed: eventual for feeds, search, and analytics; strong for the handful of operations that move money or allocate scarce resources.
"Eventual consistency means you might lose writes."
Durability and consistency are separate properties. An acknowledged write is persisted; what is weak is when other readers see it. Writes do get lost in practice, but through last-write-wins conflict resolution discarding a concurrent update - which is a resolution-policy choice, not an inherent property of the model.
"Adding an eventually consistent cache in front of the database gives us the same guarantees with more speed."
It gives you a second copy with its own staleness window and its own invalidation bugs. You have not sped up a consistent read; you have made some reads fast and weakened them, and you now own the invalidation logic. That is often a good trade - but price it as a consistency change, not just a performance change.
Why It Was Built This Way
The constraint is physical. Replicas are separated by a network that can delay and drop messages, and no amount of engineering removes that. If you insist that every read reflects every acknowledged write, then during a network partition the replicas that cannot reach a quorum have to refuse service - because answering would risk returning a value they cannot confirm is current. That is the CAP result in operational terms: when the network splits, you choose between refusing requests and answering possibly-stale ones.
Eventual consistency is what you get when you decide, in advance, that refusing is the worse outcome. It was adopted at scale by systems whose operators had measured that outage minutes cost far more than brief disagreement between replicas - a shopping cart that accepts an item under partition and merges later earns more than one that returns an error. What was traded away is the simplest and most valuable property a datastore can offer: a single global order of events that every reader agrees on. Once you give that up, correctness arguments that were previously free become your responsibility - uniqueness, invariants across two records, and "check then act" sequences all have to be redesigned or pushed to a component that still has a total order.
There is a second, quieter cost: the complexity moves from the database into your application and your runbooks. Conflict resolution is now a product decision about which user's edit matters. Reproducing bugs is now a matter of knowing which replica served which read, so you need request-level tracing of replica and lag, not just query logs. That migration of complexity is the thing to weigh when you choose. Eventual consistency is not a weaker system - it is a system that bought availability and latency with a budget drawn from your team's ability to reason about time.
Related Briefs
What to Read Next
- what is the CAP theorem
- quorum reads and writes explained
- what are CRDTs and when to use them
Eventual consistency is a per-operation decision, not an architectural identity. Make the list: for each read in your system, write down what breaks if the value is a few seconds old - and if the honest answer is "nothing a retry wouldn't fix", take the availability and the latency. For the small set where the answer is money, inventory, or a uniqueness rule, route those through a single authoritative writer and stop trying to be clever about it.
댓글
댓글 쓰기