MongoDB Replica Set Oplog Lag

Hakim Yusof 40 Reputation points
2026-09-19T01:16:27.8033333+00:00

A secondary MongoDB node is falling behind the primary and approaching the end of the available oplog window. What is the recommended way to increase the oplog size without causing replication downtime

Windows for business | Windows Server | Storage high availability | Clustering and high availability
0 comments No comments

Answer accepted by question author
Jason Nguyen Tran 26,970 Reputation points Independent Advisor
2026-09-19T02:08:16.23+00:00

Hi

When a secondary node starts approaching the end of the available oplog window, the priority should be to increase the oplog retention period before the secondary falls too far behind and requires a full resync. The good news is that modern MongoDB deployments allow you to increase the oplog size online without taking the replica set offline.

Before making changes, I recommend checking the current replication lag and oplog window to understand how much additional headroom is required. As a general best practice, size the oplog to comfortably cover your peak write volume plus any expected maintenance or outage windows. This helps ensure that secondaries have enough time to catch up during periods of heavy load or temporary network issues.

When increasing the oplog size, make sure sufficient free disk space is available on the affected replica set member. Apply the change during a maintenance window if possible, and continue monitoring replication lag, disk utilization, and the oplog window afterward to confirm the adjustment achieved the desired effect. If lag continues to grow even after enlarging the oplog, investigate underlying causes such as slow storage, network bottlenecks, long-running operations, or resource contention on the secondary.

In many environments, increasing the oplog is only part of the solution. Improving secondary performance and reducing write pressure during peak periods can be just as important for maintaining healthy replication. A combination of adequate oplog sizing and ongoing monitoring typically provides the most reliable long-term result.

I hope this helps point you in the right direction. If you find this answer helpful, please hit "accept answer" so I know it addressed your concern.

Jason

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

0 additional answers

Sort by: Oldest

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.