I went into this expecting Redis's appendfsync everysec setting to lose roughly a second of writes if the process died mid-stream, because that is what the documentation says to expect. Across three separate crash tests, it lost nothing. Figuring out why took me somewhere more interesting than the number itself: a close look at what "the process died" actually means, and how different that is from what the docs are describing.
That sent me down a longer road than one setting. I ended up measuring what it costs to turn Redis's append-only log on while an instance is already serving writes, what the fsync policy you pick does to it under load, and what each option actually gets you back when something goes wrong. I ran Redis 7.0.15 (the version Ubuntu 24.04 ships) on a single machine, in its own data directory, talking only to my own benchmark clients. Nothing here touched a cluster or a cloud service.
What durability costs while nothing is going wrong
First, the boring case: a client doing synchronous SET calls, one at a time, against three persistence modes, each one run three times for five seconds:
| mode | ops/sec (fastest run) | avg latency |
|---|---|---|
| no persistence | 14,791 | 0.067 ms |
appendfsync everysec | 14,148 | 0.070 ms |
appendfsync always | 4,295 | 0.232 ms |
everysec is effectively free, which matches what the Redis docs promise: the write still goes into a buffer, and a background thread fsyncs it once a second regardless of how many commands happened in between. always fsyncs on every single write, and single-client throughput fell to about a third of baseline. That is the number people usually quote, and it held up.
What surprised me was what happened when I stopped using one client and used a lot of them. I ran redis-benchmark at four concurrency levels against the same two fsync modes:
| clients | everysec (p50) | always (p50) |
|---|---|---|
| 1 | 23,742 rps (0.039 ms) | 4,743 rps (0.207 ms) |
| 10 | 142,045 rps (0.047 ms) | 24,808 rps (0.383 ms) |
| 50 | 130,890 rps (0.207 ms) | 86,207 rps (0.519 ms) |
| 200 | 112,740 rps (0.903 ms) | 131,926 rps (1.239 ms) |
At one client, always is roughly a fifth of everysec's throughput. By 200 clients, always is not just competitive, it is slightly ahead. Redis batches concurrent writers behind a single fsync call when it can, so the fixed cost of calling fsync() gets paid once per batch rather than once per command. If your production traffic looks like one client hammering Redis in a tight loop, always genuinely is a third of your throughput. If it looks like a web app with a couple of hundred concurrent requests, the gap I expected to see mostly wasn't there.
Turning it on without stopping anything
The part of this I actually cared about was the moment of switching, not the steady state either side of it. I loaded roughly 1.58 million keys (about 910MB resident) with no persistence running, then ran CONFIG SET appendonly yes against the live instance while a client kept writing in the background.
CONFIG SET appendonly yes doesn't just flip a flag. It forks the process and writes a full AOF base file there and then, the same way a snapshot would. On this dataset that fork finished in aof_last_rewrite_time_sec: 5, and produced an appendonlydir of 801MB next to a dump.rdb I'd taken earlier at 787MB for the same data. In terms of client-visible latency, exactly one SET call, 2.57 seconds after I issued the command, took 8.27 milliseconds. Nothing else moved. No pause, no rejected commands, no timeout.
I'd expected a bigger flinch than that, because "forking a gigabyte-sized process" sounds like the kind of thing that should stall everything briefly. At under a gigabyte of resident memory, it didn't. I ran a separate, explicit BGSAVE against the same dataset three times to check this wasn't a fluke: the worst single write each time landed at 18.8ms, 8.6ms, and 17.4ms, always in the second right after the fork, and never visible in the overall throughput or p99 for that run. The fork cost is real, but on datasets in the hundreds-of-megabytes range it shows up as one slow write, not an outage. I'd expect that to change at tens of gigabytes, which I didn't have time to test.
The rewrite that doesn't finish quietly
AOF files grow forever unless something rewrites them, so Redis periodically runs BGREWRITEAOF to compact the log back down to a fresh base file. I forced one under appendfsync always, which is the worst case, and watched per-second latency through the whole thing:
| window | no-appendfsync-on-rewrite no (default) | no-appendfsync-on-rewrite yes |
|---|---|---|
| during the rewrite body | ~0.32–0.44 ms avg, ~2,250–3,100 ops/sec | ~0.07–0.08 ms avg, ~12,000–13,500 ops/sec |
| when the rewrite finishes | one write at 143.7ms, one at 149.3ms | one write at 131.1ms, one at 110.0ms |
The setting does exactly what it says: with it off, Redis keeps fsyncing every write throughout the rewrite, so you pay the full always tax the entire time. Turn it on and the main process stops fsyncing while the child is working, and steady throughput during the rewrite jumps roughly fivefold back to normal everysec-ish levels. But the moment the rewrite finishes and the new AOF file has to be adopted, both configurations ate a stall in the 110–150 millisecond range. The setting buys you the body of the rewrite back. It does nothing for the handover at the end. I had assumed, going in, that this flag made AOF rewrites cheap. It makes the long middle part cheap. The expensive bit is a fixed cost either way.
What actually survives when the process dies
This is the one that mattered most to me, so I built an explicit test: a client pushes incrementing integers onto a Redis list as fast as it can, logging every value the server has acknowledged, while a second process sends SIGKILL to the Redis server itself three seconds in. Then I restart Redis from whatever it left on disk and compare.
| persistence | client-confirmed writes | writes actually recovered |
|---|---|---|
| none | 2,309 | 0 |
| RDB, one snapshot mid-stream | 2,285 | 1,059 |
AOF, everysec | 2,433 | 2,433 |
AOF, always | 1,954 | 1,954 |
No persistence loses everything, which is exactly what you'd expect from data that only ever lived in RAM. RDB with a single snapshot roughly halfway through lost everything written after that snapshot, 1,226 of 2,285 acknowledged writes, which is also exactly what the "snapshot" model promises: you get back to the last picture, not a moment before the crash.
What I didn't expect was the everysec row. Redis's own docs describe that setting as fast, "and you may lose 1 second of data if there is a disaster." I read that as "the process dies, you lose up to a second," which is why I expected a three-second test to show some loss. I lost nothing, in either fsync mode. Rereading it afterwards, the docs actually say "disaster," not "process crash," and that word is doing real work: kill -9 only kills the Redis process, it does not touch the operating system's page cache. Every write() Redis made to the AOF file had already reached the kernel before I ever sent the signal, fsync or no fsync, so none of it was gone. A process dying and a machine losing power are different failures, and I'd been reading the warning as if it covered both. My own test couldn't have shown that one-second window even if I'd wanted it to, since I never actually took the kernel down. That is worth knowing before you trust a "we tested crash safety" claim that was really just a process kill, mine included until I looked closer.
What it refuses, and what it quietly defers
A second BGSAVE while one is already running gets a flat ERR Background save already in progress. A BGREWRITEAOF issued during that same window doesn't error at all — it replies Background append only file rewriting scheduled and sets aof_rewrite_scheduled:1, then runs once the snapshot finishes. One operation refuses outright; the other politely queues itself. I'd assumed they'd behave the same way.
What I got wrong on the way
My first attempt at the RDB row in the crash table was wrong, and it took me a while to notice why. I called BGSAVE and then started the write-and-kill script, which meant the snapshot was taken against an empty database before a single key existed. Naturally, recovery showed zero keys, and for a few minutes I believed that meant RDB had lost literally everything in a three-second window, which would have been a much bigger story than the real one. The actual test needed the snapshot fired while the writer was already running, so the file captured a real midpoint. Once I fixed the ordering, the result dropped from "RDB lost all of it" to the far less dramatic "RDB lost everything after the snapshot it had," which is just the feature working as documented. It's a reminder that a persistence test is a timing test first, and I almost shipped a timing bug as a finding.
Run it yourself
# start an isolated instance mkdir -p ./data redis-server --port 6400 --dir ./data --save '' --appendonly no --daemonize no & sleep 1 # switch to AOF live, no restart, while writes keep happening redis-cli -p 6400 config set appendfsync everysec redis-cli -p 6400 config set appendonly yes # watch the moment it happens redis-cli -p 6400 info persistence | grep -E 'aof_enabled|aof_rewrite_in_progress|aof_last_rewrite_time_sec' # force a rewrite and watch it from another terminal redis-cli -p 6400 bgrewriteaof redis-cli -p 6400 --latency # the crash test: write, kill, restart, compare redis-cli -p 6400 rpush events 0 kill -9 "$(pgrep -f 'redis-server.*:6400')" redis-server --port 6400 --dir ./data --save '' --appendonly yes --daemonize no & sleep 1 redis-cli -p 6400 llen events What I'd actually do
I'm turning appendonly yes with everysec on for the Redis instances I run, today, because the steady-state cost is close enough to zero that I can't justify not having it. I'm not going near appendfsync always unless I already know my write pattern is concurrent rather than serial, since the two modes behave almost oppositely depending on that one fact. And I'm going to stop treating "I tested what happens when it crashes" as a settled question until I've checked whether my test killed the process or actually took the machine down, because those produced completely different answers to the same question, and only one of them is what the documentation is actually warning about.


