Part 5 of 5 · 4 min read
Exercises
Easy
Easy 1: Name why multi-leader replication exists (15 minutes)
State the main reason multi-leader replication exists, compared to single-leader replication.
Done when: letting writes happen locally and quickly for users spread across distant locations is correctly described.
Hint
It lets writes happen locally and quickly for users spread across distant locations, rather than routing every write to one single, potentially far-away leader.
Easy 2: Define a write conflict (15 minutes)
State, in one sentence, what a write conflict is.
Done when: two leaders each accepting a change to the same data before hearing from each other is correctly described.
Hint
Two different leaders each accept a change to the same data item before either has received the other's change.
Easy 3: Name three conflict resolution strategies (15 minutes)
Name the three conflict resolution strategies covered on this page.
Done when: last-write-wins, fixed-priority, and merge are all correctly named.
Hint
Last-write-wins, fixed-priority, and merge.
Medium
Medium 1: Decide if a scenario is a write conflict (25 minutes)
A leader in region A updates a row, and thirty seconds later, after that change has already replicated to region B's leader, region B's leader updates the same row. Determine whether this is a write conflict.
Done when: no is correctly concluded, since region B's leader had already received region A's change before making its own update, meaning there was a single, known ordering rather than two simultaneous, unaware changes.
Hint
No, since region B's leader had already received region A's change before making its own write, so there was a clear, single ordering rather than two unaware, simultaneous changes.
Medium 2: Explain why last-write-wins can silently discard a legitimate change (25 minutes)
Explain why last-write-wins resolving a conflict is not necessarily the same as resolving it correctly.
Done when: the explanation correctly notes last-write-wins discards the earlier write entirely based purely on timestamp, even if that earlier write was just as legitimate and intentional as the one that happened to arrive later.
Hint
Last-write-wins discards the earlier write purely based on its timestamp being earlier, even though that earlier write could have been just as legitimate and intentional as the one that happened to arrive later.
Medium 3: Choose a resolution strategy for shopping cart items (30 minutes)
Two leaders each independently accept an add-item-to-cart write for the same customer's cart, each adding a different item, before either leader has heard from the other. Decide which resolution strategy fits this scenario best, and explain why.
Done when: a merge strategy is reasonably chosen, citing that discarding either addition with last-write-wins would incorrectly lose a legitimate item the customer actually added.
Hint
A merge strategy, since discarding either addition with last-write-wins would incorrectly lose an item the customer genuinely added to their cart.
Hard
Hard 1: Explain why single-leader replication cannot have write conflicts (30 minutes)
Explain, by contrasting with multi-leader replication, why single-leader replication, covered two pages ago, cannot produce a write conflict at all.
Done when: the explanation correctly notes every write in single-leader replication passes through the one leader, giving every change a single, unambiguous order, whereas multi-leader replication has no single point enforcing that order across leaders, which is exactly what makes a conflict possible.
Hint
Every write in single-leader replication passes through the one leader, giving every change one unambiguous order; multi-leader replication has no equivalent single point enforcing order across its multiple leaders, which is exactly what allows two leaders to each accept a conflicting change independently.
Hard 2: Explain the risk of relying on clock synchronization for last-write-wins (35 minutes)
Explain what could go wrong with last-write-wins if the clocks on two different leaders are not well synchronized with each other.
Done when: the explanation correctly notes that if one leader's clock runs ahead of the other's, a write that actually happened earlier in real time could be stamped with a later timestamp than it deserves, causing last-write-wins to pick the wrong write as the "winner" based on inaccurate timing information.
Hint
If one leader's clock runs ahead, a write that actually happened earlier in real time could receive a later timestamp than it deserves, causing last-write-wins to incorrectly favor the wrong write based on inaccurate timing rather than the true order of events.
Hard 3: Weigh multi-leader replication's benefit against its conflict risk for a specific scenario (40 minutes)
An application has users concentrated in one single region, with no users anywhere else, but is considering multi-leader replication anyway, reasoning that more leaders must be better. Evaluate whether multi-leader replication is actually a good fit here.
Done when: the evaluation correctly concludes multi-leader replication is a poor fit, since its main benefit, reducing write latency for geographically distant users, does not apply when all users are concentrated in one region, while still introducing the real complexity and risk of write conflicts for no corresponding benefit.
Hint
Multi-leader replication is a poor fit here, since its main benefit, reduced write latency for geographically distant users, provides no value when all users are in one region, while still introducing the real risk and complexity of write conflicts for no corresponding benefit.