Skip to content

Consistency and time: recap and quiz

  1. 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.
  2. 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.
  3. 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.
  4. 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.
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”
  1. What would a person notice? Name the symptom first: your own write missing, an answer before its question, two readers disagreeing. (Consistency models)
  2. What is the weakest model that rules it out? Every step up costs waiting and, when the network is cut, availability.
  3. 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)
  4. 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.
  5. What do you pay on a good day? The latency of waiting for the other copies, per request. (CAP and PACELC)
  6. 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)
  7. Is it enough to order by cause and effect? A Lamport clock does that, and a vector clock also detects conflicts. (Logical clocks)

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.

Question 1 of 7

Alice saves a document and the system acknowledges it. A moment later she phones Bob, who opens the document and sees the old version. Everything else about the system works as designed.

Which of these models does that history break?

Choose one answer.

Question 2 of 7

A site shows a user their own comment right after they post it. Other visitors may see it a few seconds later, and nobody minds.

What is the weakest model that makes this feature correct?

Choose one answer.

Question 3 of 7

In the clock lab, P1 publishes a post at 10 ms true time, and P1's clock is exact. P2 replies at 40 ms true time, and P2's clock is 50 ms behind true time.

By how many milliseconds is the reply stamped before the post?

Enter a number and choose its unit.

ms
Question 4 of 7

Two writes to the same key are made one after the other, the second caused by the first. The second is made on a machine whose clock is 50 ms behind. The system keeps the write with the larger timestamp.

What is kept?

Choose one answer.

Question 5 of 7

A team puts a Lamport clock on every event of its system.

Which statements are true? Select all that apply.

Choose every answer that applies.

Question 6 of 7

Two versions of an object carry the vector clocks [3, 1, 0] and [2, 2, 0], with one entry for each of three nodes.

How are the two versions related?

Choose one answer.

Question 7 of 7

A replicated database has no network partition at the moment. Every node is up, and every message arrives.

According to PACELC, what trade-off does the system still make?

Choose one answer.

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.