Here are some example problems and possible solutions for replication lag
1. Post not instantly show
when user post the comment under a passage, he want to see it immediately, otherwise, he would think something wrong. When we user asynchronous replication, the comment may not be replicated to follower nodes. So we need to implement the read-after-write consistency to avoid it.
we assume the leader node always be synchronized with the action, based on it we can expect user will read something they've edit. for example, a user will edit his own profile instead of others, they can always read it from the leader node to make sure the read-after-write consistency.
keep track of the last updated time, for example user edited on 3:15, during 3:15 - 3:16 we always read from leader node.
client can remember of timestamp of write, read from whoever has it or wait util it has
2. Monotonic Reads
Users may not expect to see something they've seen is disappeared.
It happens when user read from different replicas, one have small lag, and the other have a greater lag.
The solution for this would be ask user read from same replica always, it may not read the latest data, but they will see the data sequentially
Top comments (0)