Video in progress
What odd situations does a user see in a system with eventual consistency, and how do you soften them?
The most common: not seeing what you just wrote, data "going backward" when you refresh the page (a monotonic reads violation), and seeing the answer before the question (a causal order violation). You soften them with session-bound guarantees.
📖 Answer
"Eventually the same" means anything can be visible in the meantime. To the user, that looks like a bug.
A read-your-writes violation. I wrote a comment — it's not on the page. The fix: route the user who wrote to the primary for a short while, or show it optimistically on the client (put the written comment into the feed without waiting for the server).
A monotonic reads violation. On the first refresh, 15 likes; on the second, 12. The two requests hit two different replicas, and one is behind. The fix: pin the user to one replica (by a hash of the user ID), or have the client send the last version it saw and the server won't answer from a replica older than that.
A causal order violation. In a chat, the message "Yes, I agree" shows up before the question "Shall we meet tomorrow?". The two messages came through two partitions or two replicas. The fix: route related events to one partition (by chat ID) and rely on the sequence number the server issues.
Things can also disappear and come back: a deleted item reappears for a moment. Often the cause is a stale copy in a cache.
In practice, first I find out for which data this is acceptable: if the like count is wrong for 2 seconds, nobody is hurt; a balance or a stock level is a different matter, and eventual consistency doesn't belong there. Honesty in the UI helps too: a "Saving..." state makes users patient.
Sign up to mark studied questions and save your progress.