Quick revision
The short answer
The 700 ms spikes every 20 minutes match the RDB snapshot rule save 1200 10000: each BGSAVE forks the 38 GB process, and the fork call copies page tables on the main thread, which on a cloud VM takes hundreds of milliseconds. I would prove it with the latency monitor (LATENCY LATEST and LATENCY HISTORY fork) and latest_fork_usec in INFO stats, check the logs for AOF fsync stalls, and fix it by making sure transparent huge pages are off, moving snapshots to a replica, using smaller shards and choosing instance types with fast forks.
What to remember
In this answer, we saw that the 20-minute spikes come from RDB snapshots: fork copies the page tables of a 38 GB process on the main thread, which takes about 700 ms on this VM, and SLOWLOG cannot see it. The latency monitor, LATENCY LATEST, LATENCY HISTORY fork and latest_fork_usec prove it, and the logs show any AOF fsync stalls. Turning off huge pages, moving snapshots to a replica, using smaller shards and faster-forking instances fix it, and keeping the latency monitor on catches the next case.
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 700 ms spikes every 20 minutes match the RDB snapshot rule save 1200 10000: each BGSAVE forks the 38 GB process, and the fork call copies page tables on the main thread, which on a cloud VM takes hundreds of milliseconds. I would prove it with the latency monitor (LATENCY LATEST and LATENCY HISTORY fork) and latest_fork_usec in INFO stats, check the logs for AOF fsync stalls, and fix it by making sure transparent huge pages are off, moving snapshots to a replica, using smaller shards and choosing instance types with fast forks.
Why this question is asked
Periodic latency spikes with an empty slow log are one of the most recognisable Redis patterns, and also one of the most commonly misdiagnosed, because the cause is not a command at all. Interviewers ask this to see whether we know the latency monitor, can connect a spike to a persistence setting, and can choose fixes that remove the cause instead of hiding it. In this answer, we will recap why fork pauses Redis, enable the latency monitor and read its output, confirm the fork with INFO, look at the disk side of persistence, and then fix and verify.
1A Quick Recap: Why fork Pauses Redis
With save 1200 10000, Redis takes an RDB snapshot when at least 10,000 keys have changed in the last 1,200 seconds, which on a busy primary means every 20 minutes. To snapshot without stopping, Redis calls fork(): the child process writes the data to disk while the parent keeps serving clients, and the two share memory through copy-on-write.
But fork itself is not free. Before it returns, the kernel must copy the parent's page tables, the structures that map virtual memory to physical pages. With 4 KB pages, 38 GB of memory needs about 76 MB of page tables, and copying them takes time, which on some virtual machines is much slower than on bare metal. During that time the main thread is inside the fork call, so no client is served. SLOWLOG never sees it, because no command was executing.
2Turning On the Latency Monitor
Redis has a built-in latency monitor that records events slower than a threshold, but it is off by default (latency-monitor-threshold 0). We set the threshold in milliseconds, and from then on Redis records the latest and the maximum duration of each event type and keeps a short history per event.
Other event names point to other causes: aof-write-pending-fsync and aof-fsync-always for disk stalls, expire-cycle and eviction-cycle for housekeeping, command and fast-command for slow commands. Here only fork appears, and its history lines up with the 20-minute rhythm.
3Confirming the Fork With INFO and the Logs
INFO stats has latest_fork_usec, the duration of the last fork in microseconds. A value of about 700,000 is 700 ms and matches the spike exactly. INFO persistence shows rdb_last_bgsave_status and the time of the last save, which we can line up with the spike timestamps.
There is a second, smaller effect to check. While the child writes the snapshot, the disk is busy, and with AOF everysec the background fsync may take longer than usual. When the fsync falls behind, Redis delays writes and logs a line like 'Asynchronous AOF fsync is taking too long (disk is busy?)'. If those lines appear during snapshots, part of the spike is disk contention. The setting no-appendfsync-on-rewrite yes skips fsync while a child is saving, which removes those stalls, at the cost of possibly losing more data if the server crashes during the save.
8 messages in order. Play them, or step through them one at a time.
The stall is inside fork(), before any data is written.
4Fixing It
First, make sure transparent huge pages are off. With huge pages enabled, copy-on-write after the fork duplicates 2 MB at a time, which adds latency and memory spikes after the fork. Redis 6.2 and later disable them for their own process with disable-thp, but older setups or kernels configured as always need checking.
Second, move snapshots off the primary. The replica holds the same data, so running RDB snapshots there (and setting save "" on the primary) removes the fork from the primary entirely. The primary still forks for full replica syncs, but those are rare.
Third, use smaller shards. Fork time grows with memory, so splitting 38 GB into four shards of about 10 GB makes each fork roughly a quarter as long, which brings 700 ms to around 175 ms or less. Finally, instance types differ: some virtualisation platforms fork much faster than others, and bare-metal or newer instance families often show far lower latest_fork_usec for the same memory.
Note that AOF rewrites also fork, so with AOF on the primary we should check how often BGREWRITEAOF runs (auto-aof-rewrite-percentage and auto-aof-rewrite-min-size) and expect those forks to shrink with smaller shards too.
5Verifying the Change
After each change we compare latest_fork_usec and the client-side p99 and p999 before and after. With snapshots on the replica, the primary's LATENCY HISTORY fork should go quiet except for rare resyncs, and the 20-minute spikes should disappear from the application's dashboards.
The latency-monitor threshold should stay set permanently. It costs almost nothing, and the next time something periodic happens, LATENCY LATEST will already have the answer.
6Follow-up questions
Why do huge pages make copy-on-write worse after a fork?
After fork, parent and child share pages until one of them writes. The first write to a shared page makes the kernel copy that page. With 4 KB pages, changing one key copies 4 KB; with 2 MB transparent huge pages, the same change copies 2 MB. Under 30,000 writes per second this multiplies memory growth and the time spent copying, which shows up as latency spikes and high RSS during every snapshot.
Could we just snapshot less often?
Yes, save 3600 10000 would halve the number of spikes, but each spike would still be 700 ms. It reduces how often users suffer, not how much. Moving snapshots to a replica or shrinking the shard removes or shortens the pause itself.
Does diskless replication avoid the fork?
No. With repl-diskless-sync, the primary still forks a child that streams the snapshot to the replica over the socket instead of writing a file first. It avoids disk I/O, not the fork.
7Conclusion
In this answer, we saw that the 20-minute spikes come from RDB snapshots: fork copies the page tables of a 38 GB process on the main thread, which takes about 700 ms on this VM, and SLOWLOG cannot see it. The latency monitor, LATENCY LATEST, LATENCY HISTORY fork and latest_fork_usec prove it, and the logs show any AOF fsync stalls. Turning off huge pages, moving snapshots to a replica, using smaller shards and faster-forking instances fix it, and keeping the latency monitor on catches the next case.
Open with
The spike pattern matches the snapshot rule: save 1200 10000 on a busy primary means a BGSAVE every 20 minutes, and BGSAVE forks. The fork call runs on the main thread and has to copy page tables for 38 GB, which on a VM can take hundreds of milliseconds, and since no command is executing, SLOWLOG is empty.
Then, if they want more
To prove it, I would set latency-monitor-threshold to 100 with CONFIG SET, then check LATENCY LATEST and LATENCY HISTORY fork, which should show fork events of around 700 ms every 1,200 seconds; LATENCY DOCTOR summarises it. INFO stats latest_fork_usec of about 700,000 confirms it.
I would also check the log for 'Asynchronous AOF fsync is taking too long', which means the disk is busy while the child writes; no-appendfsync-on-rewrite yes reduces that at the cost of a bit more possible data loss.
Fixes: make sure transparent huge pages are off, move RDB snapshots to a replica and disable them on the primary, split into smaller shards so each fork is shorter, and prefer instance types with fast fork behaviour. Then I compare latest_fork_usec and p99 before and after, and keep the latency monitor on permanently.
About this answer
- Last updated
- 13 November 2026
- Versions it names
- Redis 6
- 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 "How do you use the LATENCY monitor and INFO to prove the cause, and what do you change?": https://scrivio-interview-library.netlify.app/databases/redis-internals/747e98ab1a/