Quick revision
The short answer
The replica is stuck in a full-sync loop: while the primary creates, sends and the replica loads a 25 GB snapshot, the writes arriving at 12,000 per second fill the replica's output buffer past its limit (256 MB hard, or 64 MB for 60 seconds), so the primary drops the replica and the next attempt starts from scratch. The 1 MB default backlog is why a 30-second blip needed a full sync at all. We break the loop by temporarily raising the replica buffer limit, size the backlog for real disconnections, shorten each sync, and alert on full syncs.
What to remember
In this answer, we saw that the replica was stuck in a loop in which every full sync of 25 GB lasted longer than the replica output buffer could absorb the 2.4 MB per second write stream, so the primary dropped the replica and the sync started over. The 1 MB backlog was why the blip needed a full sync in the first place. We broke the loop by raising the replica buffer limit after checking memory headroom, sized the backlog for real disconnections, shortened syncs with diskless replication and smaller shards, and added alerts on sync_full, sync_partial_err and the replica link status.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
The replica is stuck in a full-sync loop: while the primary creates, sends and the replica loads a 25 GB snapshot, the writes arriving at 12,000 per second fill the replica's output buffer past its limit (256 MB hard, or 64 MB for 60 seconds), so the primary drops the replica and the next attempt starts from scratch. The 1 MB default backlog is why a 30-second blip needed a full sync at all. We break the loop by temporarily raising the replica buffer limit, size the backlog for real disconnections, shorten each sync, and alert on full syncs.
Why this question is asked
This failure is nasty because it looks like self-healing: the replica reconnects, a sync starts, the primary forks, and a few minutes later it all starts again. Meanwhile the primary burns CPU and memory on every fork, and we run without a usable replica, so a primary failure now would lose data. Interviewers ask this to see whether we can connect three settings, the backlog, the replica output buffer and the sync time, into one loop and break it safely. In this answer, we will recap what happens in a full sync, do the arithmetic for this primary, break the loop, prevent the next one and add monitoring.
1A Quick Recap of a Full Sync
When a replica cannot continue from the replication backlog, the primary performs a full synchronisation. It forks a child process that writes a point-in-time RDB snapshot of the whole dataset, either to disk or straight to the replica's socket. The replica receives the snapshot, loads it into memory, and only then can apply new writes.
New writes do not stop during all this. The primary keeps every write that arrives after the snapshot point in the replica's output buffer, a block of memory on the primary holding data destined for that replica. After the replica has loaded the snapshot, the primary sends the buffered writes and the replica is in sync. The buffer has a limit, by default client-output-buffer-limit replica 256mb 64mb 60: the replica is dropped if the buffer passes 256 MB, or stays above 64 MB for 60 seconds.
2Doing the Arithmetic for This Primary
Assume an average write of about 200 bytes in the replication stream. At 12,000 writes per second, that is about 2.4 MB per second. Now time a full sync of 25 GB: forking and producing the snapshot takes a minute or two, transferring 25 GB at around 150 MB per second takes almost 3 minutes, and loading 25 GB on the replica takes a few more. Call it 6 minutes, or 360 seconds.
- 30-second network blip
- Missed bytes still in the 1 MB backlog?YesPartial syncNoFull sync of 25 GB
- Fork, send and load the snapshotabout 6 minutes
- New writes fill the replica output buffer2.4 MB per second
- Buffer above 64 MB for 60 s, or 256 MB?YesReplica dropped, sync restartsNoSync completes
5 steps in order. Play them, or step through them one at a time.
So the replica is doomed on every attempt: the soft limit drops it after about a minute and a half, long before the sync could finish. When it reconnects, its partial data is useless and its offset unknown, so the next attempt is another full sync, with another fork, and so on forever. The log line about being scheduled to be closed for overcoming output buffer limits is printed each time.
And the loop started because of the backlog: 1 MB holds less than half a second of this write stream, so after a 30-second blip the bytes the replica missed were long overwritten, and a cheap partial sync was impossible.
3Breaking the Loop
The immediate fix is to give the buffer enough room for one complete sync. Before doing it, check the primary's headroom: INFO memory and the host's free memory must allow several extra gigabytes, because the fork's copy-on-write pages also grow during the sync.
With a 4 GB hard limit and a 2 GB soft limit held for 120 seconds, 860 MB of buffered writes fits comfortably and the next attempt completes. Once master_link_status is up and lag is near zero, we can lower the limit again to a value that still covers one full sync with margin, and persist it in the configuration file so a restart does not bring back the old value.
4Preventing the Next Loop
First, size the backlog so that ordinary disconnections end in a partial sync. A good rule is write bytes per second times the longest disconnection we want to survive, for example 2.4 MB per second times 60 to 300 seconds, which gives 150 to 720 MB. At 512 MB, our 30-second blip would have needed 72 MB from the backlog and finished in a second.
Second, make each full sync shorter. Diskless sync (repl-diskless-sync yes, the default since Redis 7.0) skips writing the RDB to disk and streams it straight to the replica. Some newer engines also send the write stream on a separate connection during a full sync, so the primary does not have to hold it in the output buffer: Valkey 8 has dual-channel replication, and other releases have their own variants, so check what your Redis version offers.
Third, keep shards small. A 25 GB primary takes minutes to sync; five shards of 5 GB each sync in about a minute and need far less buffer. Shard size is a recovery-time decision as much as a memory decision.
5Monitoring So It Does Not Repeat Silently
INFO stats on the primary has counters that tell this story: sync_full counts full syncs, sync_partial_ok counts successful partial syncs, and sync_partial_err counts partial syncs that were refused and turned into full ones. An alert on any increase of sync_full outside planned work, and on master_link_status down for more than a minute on any replica, would have shown the loop within minutes. Adding the primary's fork time (latest_fork_usec) and the count of client buffer disconnections completes the picture.
6Follow-up questions
What does the primary's memory look like during these repeated syncs?
It rises and falls in a saw-tooth. Each fork shares memory with the parent, but every page the parent writes to during the snapshot is copied, and at 12,000 writes per second many pages are touched, so the host's memory use can grow by several gigabytes per attempt. On top of that the replica output buffer grows towards its limit and the backlog stays allocated. Redis does not count replica output buffers when deciding to evict for maxmemory, so the real risk is the host running out of memory and the kernel killing Redis.
Why not just put the replica closer to the primary to make transfer faster?
Faster transfer helps, but loading 25 GB and forking still take minutes, and the write rate does not change. Placement is worth checking, yet the buffer and backlog sizes are what decide whether the sync can ever complete.
Is it safe to set the replica buffer limit to 0, meaning no limit?
It makes the loop impossible, but a replica that stops reading could then grow the buffer until the primary's host runs out of memory. A large, explicit limit is safer than none.
7Conclusion
In this answer, we saw that the replica was stuck in a loop in which every full sync of 25 GB lasted longer than the replica output buffer could absorb the 2.4 MB per second write stream, so the primary dropped the replica and the sync started over. The 1 MB backlog was why the blip needed a full sync in the first place. We broke the loop by raising the replica buffer limit after checking memory headroom, sized the backlog for real disconnections, shortened syncs with diskless replication and smaller shards, and added alerts on sync_full, sync_partial_err and the replica link status.
Open with
The replica is in a full-sync loop. After the 30-second blip it could not continue partially, because the default 1 megabyte backlog holds well under a second of this write stream, so the primary started a full sync.
Then, if they want more
That means forking, producing a 25 gigabyte snapshot, sending it and having the replica load it, which takes several minutes. During all that time, the roughly 2.4 megabytes per second of new writes are kept in the replica's output buffer on the primary, and the default replica limit is 256 megabytes hard, or 64 megabytes for 60 seconds.
So the buffer passes the soft limit after about a minute and a half, the primary drops the replica, and the next attempt starts from scratch with another fork.
To break it, I would first check the primary's memory headroom, then raise the limit temporarily, for example CONFIG SET client-output-buffer-limit replica 4gb 2gb 120, and watch master_link_status and master_sync_in_progress on the replica until it is up.
Then I would prevent a repeat: size repl-backlog-size to write bytes per second times 60 to 300 seconds, make sure diskless sync is on, use dual-channel replication if our engine offers it, and keep shards small enough that a full sync takes minutes. Finally I would alert on sync_full and sync_partial_err in INFO stats and on replica link status.
About this answer
- Last updated
- 13 November 2026
- Versions it names
- Redis 7
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Redis documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "The primary log keeps saying the replica's client was 'scheduled to be closed ASAP for...": https://scrivio-interview-library.netlify.app/databases/redis-scaling/0512cfefba/