Consistency in Distributed Systems

How consistency guarantees can be considered during understanding trade-offs?

Context and Background:

To understand topic of data consistency, let’s consider example of a distributed database which has one master/leader node (which takes write requests) and 2 slave/follower/replica nodes. The reason of having slave nodes is to delegate read request based workload (and to reduce read latencies for users situated in certain region). Now users can only write on master node, and then master node will asynchronously replicate those changes into replica nodes with help of something called as replication log (the logfile which contains changes i.e. writes made on master) over network. During this process there’s some replication lag that happens due to unreliable networks.

Now you might’ve noticed, we have consistency problem here. There is no way that writes made master are immediately available at replica nodes. To achieve more strict form of consistency, some trade-offs need to be considered. In this article, I’ve tried to explain different consistency models. For more depth information around this topic.

Eventual Consistency:

The term ‘eventual’ is highly qualitative and doesn’t give much insight into what’s time period required to get whole system consistent. Time required to reach consistency is usually calculated as time required for all the replicas to receive and implement (depending upon type of replication log sent out. If it’s query based and not result based replica needs to implement the queries) the replication log.

Causal Consistency:

This is stronger consistency model than eventual consistency and weaker than sequential as we are only concerned about related events, which are question and answer in above example.

Sequential Consistency:

This model is stronger than causally consistent model as we are dealing with total ordering of operations and not only ordering of related operations. Using this model, we can get idea about ordering of operations to identify the latest state of the system which will be consistent by nature of sequential consistency.

Linearizable Consistency:

This is stronger than sequential consistency because additional real time constraint.

Serializable Consistency:

This is the strongest consistency model which provides transactional multi-object consistency guarantee in real time.

--

--

Tech. Sports. Anime. Cinema. Music. In that order.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store