Sobes.tech
Middle+

What is LSN and how is it used to monitor replication lag?

sobes.tech AI

Answer from AI

LSN (Log Sequence Number) is a unique identifier of a position in the database transaction log, indicating a specific point in the change stream. In the context of replication, LSN is used to track how far the replica is behind the master.

To monitor replication lag, the LSN of the master and the replica are compared: the difference between them shows how many changes have not yet been applied on the replica. The smaller the difference, the closer the replica is to the current state. This helps identify delays and synchronization issues.

Example: if the master's LSN is 1000 and the replica's is 950, it means the replica is lagging by 50 changes.