Replication
Replication Lag
IntermediateHow primary-replica replication lag forms, accumulates under write pressure, causes stale reads, and how applications should handle it.
Step 1 of 5
Steady State: Replica in Sync
Under steady load, a PostgreSQL streaming replica receives WAL records from the primary nearly instantaneously. Replication lag is typically <5ms on a well-provisioned replica in the same datacenter. The replica's LSN (Log Sequence Number) closely tracks the primary's.
Primary LSN
1,000
500 writes/s
Replica LSN
998
500 apply/s
Primary1000
Replica998
Lag: 2ms: in sync
Events
LSN 990
writeP:✓ R:✓
LSN 995
writeP:✓ R:✓
LSN 1,000
writeP:✓ R:·
Steady state: 2ms lag, replica current
Key Takeaways
- →Under normal load, streaming replication lag stays under 10ms
- →LSN on primary and replica stay within a few records of each other
1 / 5