Back to results for “Architecture”
Redis › Persistence (RDB/AOF)

What is AOF rewriting, and why is it necessary as an append only file grows over time?

Intermediate

Answer

AOF rewriting compacts the append only file by rebuilding it from the current in memory dataset rather than the full history of every write command ever issued, removing redundant operations like multiple updates to the same key, which prevents the file from growing indefinitely and keeps both its size and the time needed to reload it from disk more reasonable over time.
BGREWRITEAOF -- triggers a background AOF rewrite
CONFIG SET auto-aof-rewrite-percentage 100
Real-world example A busy Redis instance automatically triggers an AOF rewrite once its append only file has grown to double its size since the last rewrite, keeping the file from becoming unmanageably large over weeks of continuous operation.

Common follow-ups: Does AOF rewriting happen automatically, or does it need to be triggered manually?;What happens to write operations that occur while a rewrite is actively in progress?