Quick revision
The short answer
With appendfsync everysec, Redis writes every command to the AOF file in the operating system's page cache before it replies, and a background thread calls fsync about once per second. So a crash of the Redis process loses nothing that reached the page cache, but a host or power failure loses whatever was not yet fsynced, and on a slow disk that window can stretch to two seconds or more. WAITAOF lets a client ask for durability on the writes that matter, and the multi-part AOF of Redis 7 makes rewrites cheaper in memory and disk, but neither changes what everysec itself promises.
What to remember
In this answer, we saw that everysec writes every command to the page cache before replying and fsyncs about once per second in the background. A process crash therefore loses almost nothing, while a host failure loses up to a second, or two seconds and more when the disk is slow and Redis postpones writes. The always and no settings trade latency against that window. WAITAOF lets us ask for fsync on chosen writes, locally and on replicas, and the multi-part AOF of Redis 7 removes the rewrite buffer, which makes rewrites cheaper without changing the durability promise.
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.
With appendfsync everysec, Redis writes every command to the AOF file in the operating system's page cache before it replies, and a background thread calls fsync about once per second. So a crash of the Redis process loses nothing that reached the page cache, but a host or power failure loses whatever was not yet fsynced, and on a slow disk that window can stretch to two seconds or more. WAITAOF lets a client ask for durability on the writes that matter, and the multi-part AOF of Redis 7 makes rewrites cheaper in memory and disk, but neither changes what everysec itself promises.
Why this question is asked
"We lose at most one second" is one of the most repeated sentences about Redis, and it is only half true. Interviewers ask this question because the gap between what a setting is believed to do and what it really does is exactly where data goes missing in production. In this answer, we will recap the path of a write, see what everysec does at each step, find the two ways the window grows beyond one second, compare it with always and no, and then look at what WAITAOF and the Redis 7 AOF layout add.
1A Quick Recap: Where a Write Lives on Its Way to Disk
The AOF, the append-only file, is a log of every write command Redis executes. After a restart, Redis replays it to rebuild the dataset.
A write passes through three places. First it sits in Redis's own memory, in a buffer of commands not yet written to the file. Then Redis calls write(), which copies the bytes into the operating system's page cache, memory that the kernel owns and will flush to disk later. Finally fsync() forces the kernel to push those pages to the physical disk and wait until the disk confirms. Only after fsync is the data safe from a power cut.
The difference matters because the two kinds of failure reach different places. If the Redis process crashes or is killed, the kernel still holds the page cache and flushes it normally, so anything that reached write() survives. If the whole machine loses power or the VM is torn down, the page cache disappears with it, so only fsynced data survives.
2What everysec Actually Does
With appendfsync everysec, Redis calls write() for the buffered commands on every cycle of its event loop, before it sends the replies for those commands. A separate background thread then calls fsync on the file roughly once per second. The main thread never waits for the disk in the normal case, which is why everysec costs very little latency.
- Client sends SETRedis executes it in memory
- Command added to the AOF bufferstill inside the Redis process
- Is a previous fsync still running?YesPostpone the write, up to 2 secondsNowrite() to the page cache now
- Reply sent to the clientthe client now believes the write is safe
- Background thread calls fsyncabout once per second
- Data on the physical disknow survives a power cut
6 steps in order. Play them, or step through them one at a time.
So the one-second figure is about host failure, not process failure. For a process crash, everysec is in practice almost as safe as always, because normally the reply goes out only after the bytes are in the kernel's hands.
3How the Window Grows Beyond One Second
A slow disk is the main way. If the background fsync from the previous second has not finished, a new write() on the same file can block behind it inside the kernel, which would freeze the single Redis main thread. To avoid that, Redis postpones the write and keeps the commands in its own buffer. It postpones for up to two seconds. After that it writes anyway, without waiting, and logs a line saying the asynchronous AOF fsync is taking too long and the disk may be busy.
Notice what this means. During those two seconds, commands may be acknowledged while they sit only in Redis's buffer, and the data already handed to the kernel is not fsynced either. A host failure at that moment can lose two seconds or more, and while writes are postponed even a process crash can lose the buffered part. On a shared or burst-limited cloud disk, fsync can take many seconds, and the real window follows the disk, not the setting.
4Comparing always, everysec and no
The two other settings sit on either side. With always, Redis fsyncs the AOF before replying, batched once per event loop cycle so many clients share one fsync. That gives near-zero loss of acknowledged writes, but each cycle now waits for the disk, so latency rises to the disk's fsync time and throughput falls sharply on ordinary disks. With no, Redis never calls fsync and leaves flushing to the kernel, which on Linux usually writes dirty pages within about 30 seconds.
| Setting | Lost on process crash | Lost on host failure | Cost |
|---|---|---|---|
| always | nothing acknowledged | almost nothing | every loop waits for fsync |
| everysec | nothing, unless writes were postponed | about 1 s, 2 s or more on a slow disk | small; spikes when disk stalls |
| no | nothing that reached write() | often around 30 s | lowest |
5WAITAOF: Asking for Durability Per Write
Redis 7.2 added WAITAOF numlocal numreplicas timeout. It blocks the client until all of its earlier writes have been fsynced to the AOF on the local node (numlocal is 0 or 1) and on at least numreplicas replicas, or until the timeout in milliseconds passes. It returns two numbers: how many local and how many replica fsyncs were confirmed.
This lets us keep everysec for the bulk of traffic and pay the fsync cost only for the writes we care about, such as submitting an order draft. It does not undo anything: if the counts come back lower than asked, the write still exists, and the application decides whether to retry, fail or accept the risk. The exact error text may differ between versions, so check yours.
6What the Multi-Part AOF of Redis 7 Changes
Before Redis 7, the AOF was one file. When it grew, Redis rewrote it in a child process, and the parent had to keep every new write in an in-memory rewrite buffer, then append that buffer to the new file at the end.
Since Redis 7.0, the AOF is a directory (appendonlydir by default) holding a base file, one or more incremental files and a manifest that lists them in order. When a rewrite starts, the parent simply opens a new incremental file and keeps appending to it, while the child writes a new base. When the child finishes, Redis updates the manifest to point at the new base plus the new incremental file and deletes the old ones. There is no rewrite buffer, so memory and disk spikes during rewrites are smaller. Notice that this changes the cost of rewrites, not the fsync policy: everysec still loses the same window on a host failure.
7Follow-up questions
What does WAITAOF return if a replica has AOF disabled?
A replica without AOF has nothing to fsync, so it cannot confirm the write and is not counted towards numreplicas. The command waits until the timeout and returns a replica count lower than we asked for, possibly zero. The local part is different: asking for numlocal 1 on a node with appendonly off returns an error straight away. Because these edge cases have changed between releases, check the documentation of your version before depending on them.
Is WAIT the same as WAITAOF?
No. WAIT only waits until replicas have received the writes in memory. WAITAOF waits until they have been fsynced to the AOF, which is a stronger and slower promise. WAIT protects against losing a single node's memory; WAITAOF also protects against power loss on those nodes.
8Conclusion
In this answer, we saw that everysec writes every command to the page cache before replying and fsyncs about once per second in the background. A process crash therefore loses almost nothing, while a host failure loses up to a second, or two seconds and more when the disk is slow and Redis postpones writes. The always and no settings trade latency against that window. WAITAOF lets us ask for fsync on chosen writes, locally and on replicas, and the multi-part AOF of Redis 7 removes the rewrite buffer, which makes rewrites cheaper without changing the durability promise.
Open with
I would first correct the claim a little. With everysec, Redis calls write on the AOF on every event loop cycle before it replies, so the data is in the kernel's page cache, and a background thread fsyncs about once a second.
Then, if they want more
If only the Redis process crashes, the kernel still flushes that data, so we lose essentially nothing. The one second applies to a host or power failure.
And it can be more than a second: if the previous fsync is still running, Redis postpones writes for up to two seconds and then writes without waiting, logging that the fsync is taking too long. On a slow or shared disk the real window follows the disk.
Appendfsync always fsyncs before replying, batched per loop, which is nearly lossless but expensive, and no leaves it to the kernel, often around thirty seconds.
Redis 7.2 added WAITAOF, which blocks the client until its earlier writes are fsynced locally and on a number of replicas, so I would use it after the few writes that must survive, like submitting an order, and keep everysec for the rest.
Redis 7 also changed the AOF into a directory with a base file, incremental files and a manifest, so rewrites no longer need an in-memory rewrite buffer. That makes rewrites cheaper, but the durability window is the same.
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 "What does everysec actually guarantee, how can it lose more than a second, and what do...": https://scrivio-interview-library.netlify.app/databases/redis-scaling/3df5fb0a22/