Redis › Persistence (RDB/AOF)

What is AOF, or append only file, persistence, and how does it differ from RDB snapshots?

Beginner

Answer

AOF persistence logs every write operation to a file as it happens, rather than periodically saving the entire dataset at once like RDB, meaning it can offer much better durability with less potential data loss since nearly every write is recorded individually, though the resulting log file can grow significantly larger than an equivalent RDB snapshot.
CONFIG SET appendonly yes
CONFIG SET appendfsync everysec
Real-world example A financial application enables AOF persistence to minimize the risk of losing recent transactions, accepting the larger file size in exchange for the much stronger durability guarantee it provides over RDB snapshots alone.

Common follow-ups: What does the appendfsync setting control, and what are the different options?;Can RDB and AOF persistence be used together at the same time?