RDB creates point-in-time snapshots of the dataset at specified intervals. AOF records every write operation received by the server, allowing more fine-grained recovery.
RDB saves data only at snapshot times. If Redis crashes before the next snapshot, recent writes after the last snapshot are lost.
appendonly yes appendfsync everysec
To enable AOF, appendonly must be set to 'yes'. The appendfsync option controls how often Redis fsyncs the AOF file; 'everysec' is a common safe setting.
Using AOF with 'everysec' fsync reduces data loss risk while keeping performance reasonable. RDB snapshots provide a backup in case AOF is corrupted.
With appendfsync everysec, Redis fsyncs the AOF file once per second. If a crash occurs just before fsync, recent writes in memory are lost.
