Sub topic 1
Why Replication Creates Consistency Questions
Prerequisites
Assume you understand basic client-server systems, networks, databases, key-value stores, and simple Python code.
Replication Creates Consistency Questions
Replication stores copies of the same data on multiple machines. It improves availability and reduces read latency. However, copies can temporarily disagree.
Suppose key x starts at 0. Client A writes 1 to one replica. Client B then reads from another replica and receives 0. The system must define whether this result is allowed.
A network delay, failed machine, or concurrent write can make replicas observe operations in different orders. Consistency is the set of rules that determines which read results are valid.
A Consistency Model Is a Contract on Histories
A consistency model is a contract describing which histories a distributed system may produce. A history records operations, their arguments, their results, and their timing.
The contract does not promise that every read returns the newest value under every failure. It defines what “newest” means and which operation order is acceptable.
Linearizability: Behaving Like a Single Copy
Linearizability requires every operation to appear as if it took effect at one instant between its start and completion. The resulting order must respect real-time order.
If A’s write completes before B’s read starts, B must see the write or a later value. A read cannot return 0 after a completed write changed x to 1.
Linearizability is useful when clients need one current, authoritative view. It can require coordination between replicas, which adds latency or reduces availability during network failures.
Sequential Consistency: One Order, No Real-Time Guarantee
Sequential consistency requires that all operations appear in one total order, and each client’s own operations keep their program order. Unlike linearizability, that order does not have to respect real-time order between different clients.
Thus, a read that starts after another client’s write completes may still appear before that write in the system-wide order. Sequential consistency is weaker than linearizability.
Exercise
A write completes before a read starts, but the read returns the old value. Is this history linearizable?
Show answer
No. The read violates real-time order. It might still satisfy a weaker model, such as sequential consistency, depending on the complete history.