Skip to content

Throttler: How to compute replication lag? #333

Answered by newborn22
newborn22 asked this question in Q&A
Discussion options

You must be logged in to vote

The function enableWrites will start a ticker which writes timestamps to hearttable table at regular intervals.

The replication lag refers to the time taken by the replic node to synchronise the binlog from the primary node.

Heartbeats inserted by the throttler to the primary node are synchronised to the replic nodes. When the throttler receives a request from the application, it requests data from the heartbeat table at a fixed interval. Then the heartbeat is subtracted from the select time to get the replication lag, the specific sql is select unix_timestamp(now(6))-max(ts/1000000000) as replication_lag from mysql.heartbeat

While the method above can not accurately represent the replica…

Replies: 1 comment 1 reply

Comment options

newborn22
Oct 17, 2023
Maintainer Author

You must be logged in to vote
1 reply
@newborn22
Comment options

newborn22 Oct 18, 2023
Maintainer Author

Answer selected by newborn22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant