Part 2 of 7 · 1 min read
The single-copy illusion
The wish to act as if there were one copy of the data.
Think of a shared whiteboard in an office. Everybody sees the same writing, and once someone writes a number, the next person to look sees it. Now copy the whiteboard to three offices. Photocopies lag, and people in different offices may read different numbers.
The books describe the aim. Replication keeps copies for speed and fault tolerance, but programmers would like to treat the system as if there were a single copy. The weaker the promise, the more surprises. The stronger the promise, the more waiting. The trade-off is between how consistent the views of different observers are, and the performance and availability of the system.
Consistency model
A consistency model is a precise promise about which views of the data different readers may see, given that the data is stored on several machines.
Example: "a read always returns the latest completed write" is one model. "Replicas agree if writes stop" is a much weaker one.
The word "consistency" is used for several things in this course. In module 1 the C of ACID meant the application's rules. In Level 4 it meant replicas agreeing. Here it means the promise about what readers see.
The ladder this page climbs, from strongest to weakest:
| Model | Short promise |
|---|---|
| Linearizability (strong consistency) | Acts like one copy, and the latest write is visible at once |
| Sequential consistency | Everyone sees operations in the same order, but maybe late |
| Causal consistency | Cause is seen before effect |
| Eventual consistency | If writes stop, copies converge |
Check yourself:
- Why would a programmer want to act as if there were one copy?
- What are the two ways the word "consistency" was used before this page?