DEV Community

Einsteinder
Einsteinder

Posted on

Problems with Replication Lag

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)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay