Module 5 · Distributed systemsLesson 47 of 886 minAdvanced
Strong vs eventual consistency
Strong consistency makes every read up to date by waiting. Eventual consistency answers immediately and catches up later.
Watch stale reads with replicas copying in the background. Turn on "Wait for replicas" and compare stale reads with how long each write takes.
This is the everyday version of the CAP trade-off: even when the network is fine, you choose between waiting for agreement and answering fast.
Strong consistency
A write isn't confirmed until enough copies have it (often a majority, or all synchronous replicas). After that, any read sees it.
- Simple for developers: the system behaves like one database.
- Slower writes: every write waits for the slowest required copy, which across regions can be 100 ms or more.
- Less available: if required copies can't be reached, writes stop.
Eventual consistency
A write is confirmed by one copy and spread to the others in the background.
- Fast and available: answers come from the nearest copy.
- Stale reads: for a short window, different readers see different values.
- Conflicts: two copies may accept different writes for the same item; the system must merge them (last write wins, or smarter merges).
In practice
Most real systems mix both:
- Strong for: money, inventory, unique usernames, permissions, anything where acting on old data does harm.
- Eventual for: feeds, counters, recommendations, search indexes, analytics.
And many databases let you choose per request. Cassandra and DynamoDB, for example, let you ask for a quorum read when it matters and a fast single-replica read when it doesn't.
Quorums
With N copies, if writes wait for W copies and reads ask R copies, then whenever W + R > N, every read overlaps at least one copy with the latest write. N=3, W=2, R=2 is a common balance between speed and freshness.