Persistence (RDB & AOF)
Valkey stores data in memory and offers two complementary persistence mechanisms — RDB (point-in-time binary snapshots) and AOF (Append-Only File command log) — or none at all when used strictly as an ephemeral cache.
RDB vs AOF#
| Mechanism | How it works | Pros | Trade-offs |
|---|---|---|---|
| RDB | Periodic point-in-time binary snapshot (dump.rdb) via background fork() | Compact files, fast restarts, great for backups | Can lose minutes of writes between snapshots |
| AOF | Appends every write command to disk (appendonly.aof) | Better durability (everysec loses at most ~1s) | Larger files, slightly higher write overhead |
| RDB + AOF | Both enabled with aof-use-rdb-preamble yes | Fast reload + strong durability | Higher disk I/O during rewrites |
Recommended durable baseline (valkey.conf)#
# Periodic RDB snapshots
save 900 1
save 300 10
save 60 10000
# Append-Only File (fsync once per second)
appendonly yes
appendfsync everysec
aof-use-rdb-preamble yes
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb
Both
BGSAVE(RDB) andBGREWRITEAOF(AOF) use OSfork()with Copy-on-Write. On Linux, setvm.overcommit_memory = 1in/etc/sysctl.confso background saves don't fail under memory pressure, and leave RAM headroom for CoW pages under heavy write load.
Inspect persistence status#
valkey-cli INFO persistence
Trigger a manual non-blocking snapshot or AOF rewrite:
valkey-cli BGSAVE
valkey-cli BGREWRITEAOF