Skip to main content
InterviewHubPRO
Section Overview
Q15

Question 15 of 50

Part 2: Core Architecture & Implementation (Mid-Level)

30%
Redis & Caching (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)

How does AOF Rewrite (BGREWRITEAOF) prevent infinite log file growth?

senior LevelSystem Design

In Simple Words: If a key is updated 10,000 times (INCR counter), the AOF file contains 10,000 lines:

  • AOF Rewrite: Redis forks a child process to inspect the current state of memory and writes the minimum necessary commands to recreate the dataset in a new file (replaces 10,000 INCR lines with one single SET counter 10000!).
  • Swaps the new compact AOF file atomically.