Part 5 of 5 · 4 min read
Exercises
Easy
Easy 1: Define replication lag (15 minutes)
State, in one sentence, what replication lag is.
Done when: the delay before a follower reflects a change already committed on the leader is correctly described.
Hint
The delay between a write committing on the leader and that change being reflected on a given follower.
Easy 2: Name what read-your-writes guarantees (15 minutes)
State what read-your-writes specifically guarantees a user.
Done when: seeing their own just-made write on their next read, regardless of replication lag, is correctly described.
Hint
Seeing their own just-made write on their very next read, regardless of any replication lag on the follower serving that read.
Easy 3: Distinguish monotonic reads from consistent prefix reads (15 minutes)
State the key difference between what monotonic reads protects against and what consistent prefix reads protects against.
Done when: monotonic reads protecting a single user's own successive reads from appearing to go backward, versus consistent prefix reads protecting causally related writes from appearing out of order, is correctly described.
Hint
Monotonic reads protects one user's own successive reads from appearing to go backward in time; consistent prefix reads protects causally related writes from appearing out of their original order to any reader.
Medium
Medium 1: Diagnose a reported bug (25 minutes)
A user reports that after updating their display name, their very next page load still showed their old name. Identify the violated guarantee.
Done when: read-your-writes is correctly identified as the violated guarantee.
Hint
Read-your-writes, since the user's own just-made write was not reflected on their very next read.
Medium 2: Diagnose a second reported bug (25 minutes)
A user reports that a shared counter appeared to decrease between two refreshes within the same second, with no corresponding action that should have decreased it. Identify the violated guarantee.
Done when: monotonic reads is correctly identified as the violated guarantee.
Hint
Monotonic reads, since a later read showed an older value than an earlier read had already shown.
Medium 3: Diagnose a third reported bug (30 minutes)
A user reports seeing a reply to a comment appear in a feed before the original comment it was replying to ever showed up. Identify the violated guarantee.
Done when: consistent prefix reads is correctly identified as the violated guarantee.
Hint
Consistent prefix reads, since a causally dependent write, the reply, appeared before the write it depended on, the original comment.
Hard
Hard 1: Propose a fix for the read-your-writes bug (30 minutes)
Propose a practical fix for the read-your-writes bug from the first medium exercise.
Done when: a reasonable fix is proposed, such as routing a user's own reads to the leader, or to the specific follower that already received their own recent write, for some window of time after that write.
Hint
Routing the user's own reads to the leader, or to the specific follower known to have already received their own recent write, for some window of time afterward, is a reasonable fix.
Hard 2: Propose a fix for the monotonic reads bug (35 minutes)
Propose a practical fix for the monotonic reads bug from the second medium exercise.
Done when: a reasonable fix is proposed, such as consistently routing a given user's reads to the same follower for the duration of their session, rather than to a potentially different, less-caught-up follower on each request.
Hint
Consistently routing a given user's reads to the same follower throughout their session, rather than potentially switching to a less-caught-up follower on each request, is a reasonable fix.
Hard 3: Explain why fixing read-your-writes does not automatically fix consistent prefix reads (40 minutes)
Explain why a system that has correctly solved the read-your-writes problem might still suffer from a consistent-prefix-reads violation.
Done when: the explanation correctly notes read-your-writes specifically protects a user's own write being reflected back to them, while consistent prefix reads concerns the relative order of two different, causally related writes, possibly from different users entirely, which read-your-writes's fix does not address at all.
Hint
Read-your-writes only addresses a user's own write being reflected back to that same user; consistent prefix reads is about the relative order of two separate, causally related writes, which could come from entirely different users, a scenario read-your-writes's fix never considers.