Eventual consistency
Eventual consistency is a model used in distributed systems, including some databases and storage systems. It allows for temporary inconsistencies between replicas of data across nodes, with the guarantee that all replicas will eventually converge to the same state. Eventual consistency is weaker than strong consistency models, like serializability or linearizability, but offers better performance and availability in distributed systems.
To illustrate eventual consistency, let's consider a simple example using a distributed key-value store. Imagine a distributed database with three nodes (Node A, Node B, and Node C) that store a value for a particular key, "item_stock." The initial value for "item_stock" is 10 on all nodes.
Now, a user wants to update the value of "item_stock" to 15. They send a write request to Node A, which updates its local value:
The system is inconsistent at this point, as different nodes have different values for "item_stock." However, the eventual consistency model allows this temporary inconsistency. Over time, the update will propagate to the other nodes:
Eventually, all nodes will have the same value:
During the inconsistency, read requests to different nodes might return different results. Eventual consistency does not guarantee that all clients will immediately see the latest update. However, it does ensure that given enough time without further updates, all nodes will eventually have the same data.
Eventual consistency is often employed in systems where high availability and low latency are more important than strict consistency. It allows the system to continue operating despite network partitions or other failures at the cost of temporary inconsistencies. Examples of systems that use eventual consistency include Amazon's DynamoDB and Apache Cassandra.
Last updated