Simple Note on Consistency Models

Salem Alqahtani
2 min readMay 31, 2022

To start, let me define what is consistency. Consistency is a property of the distributed system, which says that upon reading the objects that stored on many replicas, the results of reading operations from different clients should have some guarantee based on the consistency model.

Consistency models are a contract between a distributed system and the applications that run on it. These models are a set of guarantees made by the distributed system. Consistency models have trade-offs between the consistency guarantee of operations and ordering of operations. The consistency models affect the performance of the system based on each model. Here, I will explain two models called causal and strong consistency.

Causal consistency is a weak form of consistency that preserves the order of causally related operations. A happens-before relationship between operations captures causality.

Example:

Every arrow presents a causal relationship happen-before

Causal consistency does not order concurrent operations like f and c. We say that two operations are concurrent if we cannot tell that one happened before the other. The concurrent write operations to the same key is a conflict. To handle conflict operations, there are some rules like last-write-wins.

Linearizability/strong consistency is the strongest form of consistency. This means that all operations are executed in a way as if executed on a single machine, despite the data being distributed across multiple replicas. As a result, every operation returns an up-to-date value.

  • If operation A completes before operation B starts, the system orders A before B in real-time. This means that A is set request that wrote value X to object Y. If operation B is a get request, then the return of get from object Y is X.
  • If neither A nor B completes before the other starts, then there is no guarantee that these events will be ordered in real-time. However, there would still be some total order. This means that if A receives a confirmation before B begins, then the linearizability is guarantee. Otherwises, it is not guarantee.

--

--