DEV Community

Cover image for Eventual Consistency and Strong Consistency

Eventual Consistency and Strong Consistency

mayankjoshi profile image mayank joshi Originally published at Updated on ・2 min read

Before discussing the difference between Eventual & Strong Consistency, let's first understand consistency in distributed systems.

A consistent distributed systems are those in which all nodes see the same data at the same time. In other words, if we perform read operations after multiple write operations then a consistent system should return the same value for all the read operations and that too the value of the most recent write operation.

To understand this concept properly, I highly recommend reading about CAP Theorem.

Eventual Consistency

Eventual consistency guarantees that if an update is made to the data of a node (say node N), then the updated value will eventually be propagated to all the replicas of that node and eventually all the replica will become consistent to the original node(N). Nodes will get eventually consistent means it will take time for updates to reach other replicas.

Hence eventual consistency is a consistency model used to achieve high availability and is a weak consistency model.

Nodes that have achieved eventual consistency is often said to have converged, or achieved replica convergence.

Eventual Consistency

Eventual consistency offers high availability(low latency) at the risk of returning stale data.

The most popular system that implements eventual consistency is DNS (Domain Name System). Updates to a domain name are distributed according to a configured pattern and in combination with time-controlled caches; eventually, all clients will become consistent or see the update.

Strong Consistency

In contrast to eventual consistency, Strong consistency guarantee that if an update is made to a node (say N), then the updated value will be propagated to all the replicas(N1 & N2) of the node(N), immediately in other words after the update completes, any subsequent access (to N, N1, or N2) will always return the updated value.

Note during the time these replicas are being updated with new data, any read/write request to any of these replicas will get delayed as all replicas are busy in keeping each other consistent and once they will become consistent with the original node they will start accepting read/write request again.

As opposed to eventual consistency in strong consistency, always only one consistent state will be observed.

Strong Consistency

Eventual consistency offers low availability(high latency) but always returns fresh/updated data.

The most popular system that implements eventual consistency is relational databases. This means in relational database data viewed immediately after an update will be the same for all observers.

Further Reading
  1. CAP Theorem
  2. Database Sharding 

Discussion (0)

Editor guide