▶ Interactive Lab

Postgres Streaming Replication Lag

Adjust write rate vs replica apply rate; see lag accumulate.

Advertisement
Primary writes WAL. Replica reads + applies. If apply < write, lag grows.

What you're seeing

Postgres streaming replication: primary streams WAL records to replicas. Replicas apply them. If apply rate < write rate, lag (measured as bytes or time behind) grows.

Watch pg_stat_replication.replay_lag. Common causes of lag: replica I/O bottleneck, long replica queries blocking apply (with hot_standby_feedback), network saturation.

★ KEY TAKEAWAY
Replica lag = write rate – apply rate (integrated over time). Watch in pg_stat_replication.replay_lag.
▶ WHAT TO TRY
  • Set write > apply — lag grows.
  • Set apply > write — lag catches up.