Redis Data Persistence
Redis supports two persistence mechanisms: RDB and AOF.
RDB takes snapshots of data at specified intervals. The characteristics of RDB include a compact file format that facilitates efficient data transmission and restoration; when saving an .rdb snapshot, the parent process forks a child process to handle the actual persistence work, thereby maximizing Redis performance; compared with AOF, restoring large datasets is generally faster using RDB.
AOF (Append-only File)
AOF records every write operation performed on the server and replays these commands upon startup to restore the original data. Each command in AOF is appended and saved at the end of the file according to the Redis protocol; additionally, Redis supports background rewriting of the AOF file to prevent it from growing excessively large. The characteristics of AOF include support for different fsync strategies (no fsync, every second fsync, or after each write), where only specific operations append commands to the file, resulting in high operational efficiency; furthermore, as a log-based format, AOF files are easier to manipulate and manage compared to RDB.