Part 3 · 1 chapters · ~8 min

Persistence

RDB snapshots with fork and copy-on-write, the append-only file, fsync policies and what each can lose, AOF rewriting and the multi-part AOF, fork costs on large datasets, mixing RDB and AOF, restart times, and choosing persistence per use case.

5

Snapshots, logs and loss windows

code
# redis.conf
save 900 1 300 100 60 10000      # RDB: snapshot if 1 change in 900 s, 100 in 300 s, 10000 in 60 s
appendonly yes
appendfsync everysec
aof-use-rdb-preamble yes          # faster restarts: RDB base + AOF tail
INFO persistence                  # rdb_last_bgsave_status, aof_rewrite_in_progress, latest_fork_usec
PERSISTENCE: RDB AND AOF
snapshots, an append-only log, or both, and what each can lose
dataset in memoryRDB snapshotfork + write dump.rdbAOFappend every write commandappendfsync alwayssafest, slowestappendfsync everysec≤ ~1 s of lossappendfsync noOS decides
swipe the figure sideways, or tap expand for full screen
1/5
RDB snapshots
Redis forks; the child writes a compact snapshot of memory to disk while the parent keeps serving (copy-on-write). Fast restarts, compact backups; you lose writes since the last snapshot.
periodic point-in-time snapshotslose writes since the last snapshot