What is sequential consistency in distributed systems?

What is consistency?

In a single computer, we can guarantee that the system stores the most recently updated data. However, in a distributed system, data is shared and replicated across many computing nodes.

Consistency is a property of the distributed system which says that every node/replica has the same view of data at a given point in time. This is irrespective of whichever client has updated the data. Strong consistency would mean that the distributed system converges on a single value and the client always reads the latest data.

Consistency models

A consistency model is a contract between a distributed system and the applications that run on it. This model is a set of guarantees made by the distributed system. Different distributed systems employ various consistency models.

Examples include linearizability, serializability, causal consistency, and eventual consistency. We will talk about sequential consistency in this shot.

Sequential consistency

Sequential consistency implies that operations appear to take place in some total order. This order has to be consistent with the order of operations on each individual process.

Therefore, reads may be stable in terms of real-time, but not in logical time. However, writes are totally ordered according to logical time across all replicas.

A key difference between sequential consistency and linearizability is that linearizability may not preserve real-time ordering.

Example

In the following example, we have a distributed system consisting of four different processes: P1, P2,P3, and P4.

Several operations are happening at every process. W(Y,A) means that the value of object Y is written as A. R(Y) means that the value of the object Y is being read.

At first glance, the following sequence of operations might not make sense. This is because Y is being updated to B in P2, and when P3 reads the value of Y, it returns A. However, remember that sequential consistency only requires some total order agreed upon by individual processes.

The following global order of operations makes this system sequentially consistent:

W(Y,A), R(Y) = A, W(Y,B), R(Y) = B.

Note: With this sequential order, it makes sense that P3 reads A first and then reads B in subsequent read operations.

Distributed system

Free Resources