Various Consistencies
本記事はdev.toから移植しました.
Introduction
The word “consistency” has many meanings in computer science. In this article, we will explain the various consistency aspects of distributed system replication in a clear and straightforward manner.
Serializability
State machine replication with linearizability sorts transactions into a sequence, and that sequence is guaranteed for all replicas. This is completely independent of real-world time.
Linearizability causes the problems shown in the following figure.
Linearizability only guarantees the update order between replicas, as shown in the figure above, and there is no way to know when that information will be transmitted to other replicas. So, it is possible to read the latest value only at the replica where the latest write was performed, but it is not guaranteed that the latest value can be read at the other replicas.
Linearizability
The difference between linearizability and serializability is always the ability to read the latest value at any replica. Linearizability allows any replica to read the latest value.
The following words are synonymous with linearizability.
- Atomic consistency
- Strong consistency
- Immediate Consistency
- External Consistency
How do we achieve linearization?
Linearizability wants to make the data look like one. To do so, simply lock the whole thing when updating. Therefore, guaranteeing linearizability sacrifices availability.
Eventual Consistency
Eventual consistency means that if you stop writing to the database and wait for some unspecified length of time, then eventually all read requests will return the same value. This means that it is not known when updates to the database will stop, but it is guaranteed that identical values will eventually be read from all replicas. This is a very weak guarantee and says nothing about when the convergence will occur.