Part 6 of 6 · 3 min read
Exercises
Easy
Easy 1: Six causes (20 minutes)
A client sent "charge 20 dollars" and got no reply. List the six situations from the book and say which ones mean the charge happened.
Done when: six lines, each marked "charged" or "not charged".
Hint
In four of the six cases the request may have been processed.
Easy 2: Which clock (20 minutes)
Pick time-of-day or monotonic for: measuring request latency; a log line timestamp; a lock timeout; a "created at" field.
Done when: four choices, one reason each.
Hint
Durations use the monotonic clock. Calendar facts use the time-of-day clock.
Easy 3: Drift arithmetic (20 minutes)
A clock drifts at 200 ppm. Compute drift after 10 seconds, 1 minute and 1 hour.
Done when: three numbers.
Hint
Multiply seconds by 0.0002.
Medium
Medium 1: Timeout table (30 minutes)
Replies take 30 ms normally, and 2% of the time 500 ms. For timeouts of 50, 200 and 1,000 ms, say what fraction of healthy calls are wrongly treated as failures and how long a dead server takes to be noticed.
Done when: a table with three rows and a recommendation.
Hint
Timeouts shorter than 500 ms catch the slow 2% as false alarms.
Medium 2: LWW trace (30 minutes)
Node 1's clock is 5 ms fast. Client A writes x = 1 at node 1 (stamp 100). Client B reads it from node 2 at true time 102 ms and writes x = 2 at node 2 (stamp 99 by its clock). Show what a third node keeps and why that is wrong. Propose a fix.
Done when: a trace and a fix with a logical clock.
Hint
B's write is causally later, but its stamp is smaller.
Medium 3: Interval comparison (30 minutes)
Events A and B have readings 200 ± 10 ms and 215 ± 10 ms. Is the order known? Then for 200 ± 10 and 225 ± 10. How long must a Spanner-style system wait?
Done when: two answers and a wait time.
Hint
Non-overlapping intervals give a certain order.
Hard
Hard 1: Fix the lock (45 minutes)
A lock service gives leases of 10 seconds to workers that write to a shared file store. Show the failing timeline with a GC pause. Then redesign with fencing tokens: what does the lock service return, what does the store keep, and which request gets rejected?
Done when: a failing timeline and a fixed design.
Hint
The store, not the client, rejects the old token.
Hard 2: Failure detector design (45 minutes)
Design a failure detector for a pool of 50 servers: heartbeat interval, timeout rule, how to adapt to jitter, and how a majority confirms a death. State the false alarm cost and the slow detection cost.
Done when: a written design with numbers and two trade-offs.
Hint
Several observers must agree, as in a quorum.
Hard 3: Chaos test plan (50 minutes)
Write a test plan that injects the faults of this page into a two-service system: dropped replies, delayed replies, a paused process, a clock jump. For each, state the expected safe behaviour.
Done when: a table of four faults with injection method and expected behaviour.
Hint
Each fault needs a way to inject it and a check that shows the result.