Eventual Consistency
Eventual consistency is a consistency model guaranteeing that if no new updates are made to a data item, all replicas will eventually converge to the same value — but at any given moment, different replicas may return different values.
What It Really Means
In a strongly consistent system, after a write completes, every subsequent read returns the updated value. In an eventually consistent system, after a write completes, some reads may still return the old value for a period of time. Eventually — after propagation delays — all reads will return the new value.
"Eventually" is typically milliseconds to seconds, not hours or days. DNS propagation is a well-known exception where "eventually" can mean up to 48 hours due to TTL caching, but most eventually consistent databases converge in under a second.
The reason eventual consistency exists is the CAP theorem. During a network partition, a distributed system must choose between consistency (reject requests to maintain correctness) and availability (serve requests with potentially stale data). Eventual consistency chooses availability. For many use cases — social media feeds, product catalogs, recommendation engines, analytics — serving slightly stale data is far better than returning an error.
Eventual consistency is the default model for Amazon DynamoDB, Apache Cassandra, DNS, CDNs, and most NoSQL databases. It is not a deficiency but a deliberate design choice that enables higher availability, lower latency, and better scalability.
How It Works in Practice
The Propagation Window
When a write hits Replica A:
- Replica A acknowledges the write to the client immediately
- Replica A asynchronously propagates the change to Replicas B and C
- During propagation (the "inconsistency window"), reads from B and C return the old value
- After propagation, all replicas are consistent
The inconsistency window depends on: network latency between replicas, replication strategy (push vs. pull), and system load. In a well-configured Cassandra cluster within a single datacenter, this window is typically 10-100 milliseconds.
Stronger Variants of Eventual Consistency
Pure eventual consistency is the weakest guarantee. Most systems offer stronger variants:
Read-your-writes consistency: After you write a value, you will always read your own write (but other users may not see it yet). Implemented by routing your reads to the same replica that handled your write, or by tracking write timestamps.
Monotonic read consistency: Once you read a value, you will never read an older value in subsequent reads. Prevents the confusing scenario where a page refresh shows older data.
Causal consistency: If operation A causally precedes operation B, everyone sees A before B. Implemented using vector clocks or similar mechanisms.
Real-World: Amazon DynamoDB
DynamoDB replicates each item to three nodes within a region. Writes are acknowledged when 2 of 3 nodes confirm. Reads have two modes:
- Eventually consistent reads (default): Read from any single replica. Cheap, fast, but may return stale data.
- Strongly consistent reads: Read from the primary replica after verifying it has the latest write. Costs 2x and has higher latency.
Most DynamoDB workloads use eventually consistent reads because the inconsistency window is typically <1 second and the 2x cost savings are significant at scale.
Real-World: DNS
DNS is the largest eventually consistent system in the world. When you update a DNS record:
- Your authoritative nameserver is updated immediately
- Recursive resolvers worldwide cache the old record until its TTL expires
- After TTL expiration, resolvers fetch the new record
With a TTL of 3600 seconds, DNS changes take up to 1 hour to propagate globally. Some resolvers ignore TTL and cache longer, making propagation unpredictable. This is why DNS migrations often use a strategy of lowering TTL days before the actual change.