Replication lag measures the delay between an operation being recorded or applied on the primary and being applied on a replica. It helps reveal whether replicas are keeping pace and supports operational diagnosis. section 9.1.3
Use replication lag when evaluating replication behavior:
- Chained replication can reduce primary load, but routing a secondary through another secondary may increase lag depending on network topology. section 9.1.3
- Compare each secondary’s synced timestamp with the primary to identify members that are behind. section 9.1.3
Inspect secondary lag
Run db.printSecondaryReplicationInfo(). Its output reports each secondary’s source, syncedTo timestamp, and replLag value; one member may show 0 seconds behind while another shows 10 seconds.
Listing 9.5 Output of the db.getReplicationInfo() command
db.getReplicationInfo()
{
configuredLogSizeMB: 4096,
logSizeMB: 4096,
usedMB: 4074.63,
timeDiff: 635133,
timeDiffHours: 176.43,
tFirst: 'Wed Mar 20 2024 10:44:15 GMT+0000 (Coordinated Universal Time)',
tLast: 'Wed Mar 27 2024 19:09:48 GMT+0000 (Coordinated Universal Time)',
now: 'Wed Mar 27 2024 19:09:49 GMT+0000 (Coordinated Universal Time)'
}
Inspect db.getReplicationInfo() output to review oplog size, usage, time span, and timestamps when diagnosing replication problems. section 9.1.3

