Consistency and time: recap and quiz
The module in four sentences
Section titled “The module in four sentences”- Consistency models. A model is a promise about which histories of reads and writes are allowed: linearizability keeps real-time order, sequential consistency one total order, causal consistency only cause and effect, read-your-writes one client’s own writes, and eventual consistency only agreement if writes stop.
- CAP and PACELC. While the network is cut, a system cannot both answer every request and stay linearizable, so each node refuses, serves stale data, or answers and reconciles later; when the network works, it still trades latency for consistency.
- Physical clocks and clock skew. Clocks on different machines disagree, so sorting by timestamp can put an effect before its cause, and last write wins can keep the wrong write without an error.
- Logical clocks. Lamport clocks follow cause and effect and give every event a number, and vector clocks also tell a cause from a concurrent event, at a cost that grows with the number of processes.
How each one breaks
Section titled “How each one breaks”| Idea | What breaks | What you see | What helps |
|---|---|---|---|
| Models | A feature needs more than the store promises | A stale read that a person notices, such as a phone call after a save | Name the weakest model that keeps the feature correct |
| CAP | The network is cut | Refusals, stale reads, or two copies that drift apart | Decide the behaviour for each operation before the cut |
| PACELC | Waiting for the other copies | Writes that are slower on every good day | Choose per operation what to wait for |
| Physical clocks | A skewed clock stamps events | A reply before its post, a newer write that loses | Do not compare timestamps from different machines as truth |
| Logical clocks | Concurrent writes with no order | Conflicts that need reconciling | Vector clocks to detect them, and a merge rule to resolve them |
A checklist for reasoning about consistency and time
Section titled “A checklist for reasoning about consistency and time”- What would a person notice? Name the symptom first: your own write missing, an answer before its question, two readers disagreeing. (Consistency models)
- What is the weakest model that rules it out? Every step up costs waiting and, when the network is cut, availability.
- What does each node do when the network is cut? Refuse, serve stale data, or answer everything, for each operation, in writing. (CAP and PACELC)
- If both sides may write, how are the writes merged? Last write wins loses a write, and a merge keeps both when the data allows one.
- What do you pay on a good day? The latency of waiting for the other copies, per request. (CAP and PACELC)
- Does any decision depend on comparing timestamps from two machines? If so, how far apart can the clocks be, and what breaks at that skew? (Physical clocks)
- Is it enough to order by cause and effect? A Lamport clock does that, and a vector clock also detects conflicts. (Logical clocks)
Check your understanding
Section titled “Check your understanding”Seven questions cover the whole module. Every option is explained, whether it is right or wrong.
Consistency and time: module quiz
This quiz needs JavaScript to check your answers.
Where this goes next
Section titled “Where this goes next”This module said what a system can promise when copies disagree and clocks differ. The next one, consensus and coordination, is about how nodes agree anyway: quorums, electing a leader, and keeping an old leader from doing harm.
Your progress
Built by GhaziAlibi.
© ShardCraft. All rights reserved.