A user updates a profile on the primary and immediately reads from a replica 200 ms behind, seeing the old value. Give three mechanisms that restore read your writes, say which of them also gives monotonic reads under a replica failure, and state the cost of each.
A user updates a profile on the primary and immediately reads from a replica 200 ms behind, seeing the old value. Give three mechanisms that restore read your writes, say which of them also gives monotonic reads under a replica failure, and state the cost of each.
Approach: List where the staleness can be corrected, at the client, at the router, or at the replica, then test each against a second read served by a different replica.
Route the user's reads to the primary for a window after a write, pin the user to one replica with sticky routing, or have the client carry a version token that the replica waits to reach, and only the version token survives a replica failure with monotonic reads intact. Reading from the primary is the simplest and consumes primary read capacity, the resource replication existed to protect, and it needs a rule for how long the window lasts. Sticky routing sends a user to the same replica each time, which gives read your writes while that replica holds the write and gives monotonic reads while the stickiness holds, and it fails the moment the replica dies or the client changes network, since the next replica may be further behind. A version token is the log position the write reached, sent with every read, and the replica either waits until it has applied that position or forwards the read; this holds on any replica and costs a token per session plus a wait that appears as tail latency. Monotonic reads is the weaker property of never moving backwards, so a client that only reads still needs the token or the stickiness, because two consecutive reads served by replicas at different positions can reverse time.
Follow-up: How do you provide read your writes when the client is a browser that can be closed between the write and the read?
Key concepts: read your writes, monotonic reads, sticky routing, version token.