Part 7 of 7 · 3 min read
Exercises
Easy
Easy 1: Name the anomaly (20 minutes)
Name the anomaly and the guarantee that prevents it: a user posts and then sees no post; a comment appears and disappears on refresh; a reply is seen before the question.
Done when: three anomalies and three guarantees.
Hint
Use the table in section 1.
Easy 2: Burst backlog (20 minutes)
A follower applies 4,000 writes per second. A burst of 7,000 per second lasts 6 seconds. Compute the backlog after the burst and the time to clear it if normal traffic is 3,000 per second.
Done when: a backlog and a clearing time.
Hint
Backlog = (burst rate − apply rate) × seconds. Clearing rate = apply rate − normal rate.
Easy 3: Pick the guarantee (20 minutes)
Choose none, read-your-writes, monotonic reads, consistent prefix or leader reads for: the news feed, the user's own settings page, a payment confirmation, a comment thread, a chat window.
Done when: five choices with reasons.
Hint
Ask what the user sees if the data is one minute old.
Medium
Medium 1: Leader load (30 minutes)
A site has 60,000 reads and 3,000 writes per second. 8 percent of reads are within one minute of the user's own write and go to the leader. The leader can do 12,000 operations per second. Compute the leader load, and the highest share of such reads the leader can bear.
Done when: a load figure and a maximum share.
Hint
Leader reads = 8 percent of 60,000. Add the writes.
Medium 2: Sticky routing (30 minutes)
A site has 5 followers and 200,000 active users. Compute the users per follower with a hash route. One follower fails. Compute the new users per follower. State one remaining risk for monotonic reads.
Done when: two per-follower counts and one risk.
Hint
Users per follower = users ÷ followers.
Medium 3: Position tracking (30 minutes)
A client saves a write that gets log position 9,200. Three followers are at positions 9,150, 9,210 and 9,190. Say which can serve the client's next read, and what the system does if none can.
Done when: a list of eligible followers and a fallback.
Hint
A follower is eligible if its position is at least 9,200.
Hard
Hard 1: Cross-device design (45 minutes)
A user edits a document on a laptop and opens it on a phone one second later. The replicas span two data centres. Design how the phone sees the edit: where the position is stored, how the read is routed, and what happens when the leader's data centre is unreachable.
Done when: a numbered design with the failure case.
Hint
The position or time of the last write must be shared by both devices.
Hard 2: Chat ordering (45 minutes)
A chat app stores messages in 8 partitions by sender id. Show the anomaly this can produce. Redesign the partition key and describe what is gained and lost in write balance.
Done when: an anomaly timeline and a new key with trade-offs.
Hint
Keep the two sides of a conversation in one partition.
Hard 3: Lag budget (50 minutes)
Choose a lag budget (the highest lag you accept) for an online shop. Name the reads that need it tighter, the monitoring signal, the action when lag exceeds the budget, and the user-visible effect of that action.
Done when: a budget in seconds, a signal, an action and an effect.
Hint
Lag budgets are chosen from what users notice and the cost of leader reads.