Durability Tradeoffs
The appendfsync setting
Section titled “The appendfsync setting”AOF durability depends on how often Redis flushes the AOF buffer to disk. The appendfsync directive controls this with three modes:
always: fsync after every command — zero data loss, lowest throughputeverysec: fsync once per second — at most 1 second of data loss, good balance (recommended)no: OS decides when to flush — highest throughput, unpredictable data loss
# Maximum durability — every write fsyncedappendfsync always
# Balance — at most 1 second of data loss (recommended)appendfsync everysec
# Fastest — OS controls flushing, unpredictable lossappendfsync noWhat you can lose on a crash
Section titled “What you can lose on a crash”| Mode | Max data loss | Throughput |
|---|---|---|
always | 0 commands | Lowest |
everysec | ~1 second | Good |
no | Since last OS flush | Highest |
| RDB only | Since last snapshot | Highest |
Combining persistence with replication
Section titled “Combining persistence with replication”Running replicas does NOT replace persistence. A replica that crashes and restarts will reload from its own persistence files (or sync from primary). Best practice: enable persistence on replicas independently, not just on the primary.
127.0.0.1:6379> CONFIG GET appendfsync1) "appendfsync"2) "everysec"127.0.0.1:6379> CONFIG SET appendfsync alwaysOK127.0.0.1:6379> CONFIG GET appendfsync1) "appendfsync"2) "always"CONFIG GET appendfsync
CONFIG SET appendfsync always
CONFIG GET appendfsync