Definition:
Eventual consistency is a consistency model in distributed systems where all replicas of data will become consistent over time, but immediate consistency is not guaranteed.
It’s commonly used in highly available, distributed databases like Cassandra, DynamoDB, or Riak.
- Data is written to one node in the system.
- Changes are propagated asynchronously to other nodes.
- During propagation, different nodes may return different values.
- Eventually, all nodes converge to the same value.
Key Point:
- Immediate reads may return stale data, but system guarantees convergence eventually.
- Distributed DB with 3 nodes: A, B, C
- Initial value of
x = 10
Client updates x = 20 on Node A
Node A → B → C (asynchronously)
Before propagation:
Node A = 20
Node B = 10
Node C = 10
Eventually:
Node A = 20
Node B = 20
Node C = 20
- Reads may return stale values until all nodes are updated.
| Pros | Cons |
|---|---|
| High availability and uptime | Reads may be stale |
| Better performance & low latency | Not suitable for critical transactions |
| Fault-tolerant | Complex conflict resolution |
- Social media feeds (e.g., likes count)
- Shopping cart updates in e-commerce
- DNS replication
- Event logging systems
Imagine writing a note on a whiteboard in a classroom:
- Teacher writes the note on one board first.
- Students in other corners see it a little later.
- Eventually, all students have the same note.
💡 Key takeaway:
- Eventual consistency = “It will be correct eventually.”
- Trade-off between consistency and availability/performance (CAP theorem).