Bird
Raised Fist0
Redisquery~10 mins

Combined RDB + AOF in Redis - Step-by-Step Execution

Choose your learning style10 modes available
Concept Flow - Combined RDB + AOF
Start Redis Server
↓
Load RDB Snapshot
↓
Apply AOF Commands
↓
Data Fully Restored
↓
Serve Client Requests
↓
Periodically Save RDB Snapshot
↓
Append New Commands to AOF
↩Back to Serve Client Requests
Redis starts by loading the RDB snapshot, then replays AOF commands to restore the latest data, and continues serving clients while saving snapshots and appending commands.
Execution Sample
Redis
1. redis-server starts
2. Load RDB snapshot file
3. Replay AOF command log
4. Data restored
5. Serve clients
6. Save RDB periodically
7. Append new commands to AOF
This sequence shows how Redis restores data using RDB and AOF combined, then continues normal operation.
Execution Table
StepActionData StateResult
1Start Redis serverEmptyServer running, no data loaded
2Load RDB snapshotPartial data loadedData from last snapshot restored
3Replay AOF commandsData updatedCommands applied to reach latest state
4Data fully restoredComplete dataReady to serve clients
5Serve client requestsData changesClients can read/write data
6Save RDB snapshot periodicallySnapshot updatedNew snapshot saved on disk
7Append new commands to AOFAOF file growsCommands logged for durability
8Repeat serving clientsData changesCycle continues
9ExitN/AServer stopped or restarted
💡 Execution stops when the server shuts down or restarts.
Variable Tracker
VariableStartAfter Step 2After Step 3After Step 4After Step 5After Step 6After Step 7Final
Data in memoryEmptyPartial from RDBUpdated with AOFCompleteChanges with clientsSnapshot savedCommands appendedChanges with clients
RDB snapshot fileOld snapshotLoadedUnchangedUnchangedUnchangedNew snapshot savedUnchangedUnchanged
AOF fileOld AOFUnchangedReplayedUnchangedUnchangedUnchangedAppended new commandsUnchanged
Key Moments - 3 Insights
Why does Redis load the RDB snapshot before replaying the AOF?
Loading the RDB snapshot quickly restores a recent full state, then replaying the AOF applies only the changes since that snapshot, making recovery faster (see execution_table steps 2 and 3).
What happens if the AOF file is missing or corrupted?
Redis can still load data from the RDB snapshot but will miss recent changes not saved in the snapshot, so data may be lost (refer to execution_table step 2 without step 3).
Why does Redis keep appending commands to the AOF after loading data?
Appending commands ensures all new changes are logged for durability, so if Redis restarts again, it can replay these commands to restore the latest state (see execution_table step 7).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, what is the data state after step 3?
AData updated with AOF commands
BPartial data loaded
CEmpty
DComplete data ready to serve
💡 Hint
Check the 'Data State' column for step 3 in the execution_table.
At which step does Redis start serving client requests?
AStep 4
BStep 5
CStep 6
DStep 7
💡 Hint
Look for the action 'Serve client requests' in the execution_table.
If Redis did not save RDB snapshots periodically, which step would be missing?
AStep 2
BStep 3
CStep 6
DStep 7
💡 Hint
Check which step mentions saving RDB snapshots periodically in the execution_table.
Concept Snapshot
Combined RDB + AOF in Redis:
- On startup, load RDB snapshot (fast full data)
- Replay AOF commands (recent changes)
- Serve clients with full data
- Periodically save new RDB snapshots
- Append new commands to AOF for durability
- Combines speed (RDB) and safety (AOF)
Full Transcript
This visual execution shows how Redis uses both RDB snapshots and AOF command logs to restore data. First, Redis loads the RDB snapshot file to quickly restore a recent full state. Then it replays the AOF commands to apply all changes since the snapshot, reaching the latest data state. After data is fully restored, Redis serves client requests, allowing reads and writes. While running, Redis periodically saves new RDB snapshots to disk and appends new commands to the AOF file to ensure durability. This combination balances fast recovery and data safety. The execution table traces each step, showing data state changes and actions. The variable tracker follows memory data, RDB snapshot file, and AOF file states through the process. Key moments clarify why Redis loads RDB before AOF, what happens if AOF is missing, and why commands keep appending to AOF. The quiz tests understanding of data states and steps. This approach helps beginners see how Redis recovers and maintains data using combined persistence methods.

Practice

(1/5)
1. What is the main advantage of using both RDB and AOF persistence together in Redis?
easy
A. It disables data persistence to improve speed.
B. It combines fast startup with high data durability.
C. It reduces memory usage significantly.
D. It automatically compresses all data files.

Solution

  1. Step 1: Understand RDB persistence

    RDB creates snapshots periodically, allowing Redis to start quickly by loading a compact file.
  2. Step 2: Understand AOF persistence

    AOF logs every write operation, ensuring data durability by replaying commands after a restart.
  3. Final Answer:

    It combines fast startup with high data durability. -> Option B
  4. Quick Check:

    Combined RDB + AOF = Fast startup + durability [OK]
Hint: Remember: RDB = snapshots, AOF = logs every write [OK]
Common Mistakes:
  • Thinking combined persistence disables data saving
  • Confusing RDB with AOF roles
  • Assuming combined persistence reduces memory usage
2. Which Redis configuration option enables both RDB snapshots and AOF persistence?
easy
A. appendonly yes and save ""
B. appendonly no and save ""
C. save no and appendonly no
D. appendonly yes and save 900 1

Solution

  1. Step 1: Identify RDB snapshot setting

    The 'save 900 1' means save snapshot if at least 1 change in 900 seconds.
  2. Step 2: Identify AOF setting

    'appendonly yes' enables AOF persistence logging every write.
  3. Final Answer:

    appendonly yes and save 900 1 -> Option D
  4. Quick Check:

    Enable both RDB and AOF with save + appendonly yes [OK]
Hint: Look for appendonly yes plus save with time/count [OK]
Common Mistakes:
  • Setting appendonly no disables AOF
  • Empty save disables RDB snapshots
  • Confusing syntax for save option
3. Given Redis is configured with both RDB and AOF enabled, what happens if Redis crashes after some writes but before the next RDB snapshot?
medium
A. Data is restored from AOF log, including recent writes after last snapshot.
B. Data is restored from the last snapshot only, losing recent writes.
C. Redis starts empty with no data restored.
D. Redis merges partial snapshot and AOF, causing data duplication.

Solution

  1. Step 1: Understand RDB snapshot timing

    RDB snapshots happen periodically, so recent writes after last snapshot are not saved there.
  2. Step 2: Understand AOF recovery

    AOF logs every write, so Redis replays AOF to restore all writes including recent ones.
  3. Final Answer:

    Data is restored from AOF log, including recent writes after last snapshot. -> Option A
  4. Quick Check:

    AOF recovers recent writes missed by RDB [OK]
Hint: AOF logs all writes; RDB snapshots periodically [OK]
Common Mistakes:
  • Assuming only RDB restores data
  • Thinking Redis starts empty after crash
  • Believing Redis merges snapshot and AOF causing duplicates
4. You enabled both RDB and AOF in Redis, but after a restart, some recent data is missing. What is the most likely cause?
medium
A. Redis does not support combined persistence.
B. RDB snapshot interval was set to zero.
C. AOF file was corrupted or disabled during restart.
D. The Redis server was started with wrong port.

Solution

  1. Step 1: Check AOF role in recovery

    AOF logs all writes and is used to restore recent data after restart.
  2. Step 2: Identify cause of missing recent data

    If AOF is corrupted or disabled, recent writes after last snapshot are lost.
  3. Final Answer:

    AOF file was corrupted or disabled during restart. -> Option C
  4. Quick Check:

    Missing recent data usually means AOF problem [OK]
Hint: Check AOF file integrity if recent data missing after restart [OK]
Common Mistakes:
  • Assuming Redis can't combine RDB and AOF
  • Ignoring AOF file corruption possibility
  • Blaming wrong port for data loss
5. You want to optimize Redis persistence by combining RDB snapshots every 15 minutes and AOF with 'everysec' fsync policy. Which statement is true about this setup?
hard
A. This setup balances fast recovery and durability with minimal performance impact.
B. This setup disables AOF fsync, risking data loss on crash.
C. RDB snapshots every 15 minutes cause Redis to block all writes during save.
D. AOF with 'everysec' fsync writes data to disk after every command synchronously.

Solution

  1. Step 1: Understand RDB snapshot interval

    Snapshots every 15 minutes reduce blocking frequency and provide periodic backups.
  2. Step 2: Understand AOF 'everysec' fsync

    'everysec' fsync writes AOF to disk every second asynchronously, balancing durability and performance.
  3. Step 3: Combine effects

    This combination offers fast recovery from snapshots and durability from AOF with low performance cost.
  4. Final Answer:

    This setup balances fast recovery and durability with minimal performance impact. -> Option A
  5. Quick Check:

    RDB + AOF everysec = balanced durability and speed [OK]
Hint: Use RDB for snapshots, AOF everysec for durability and speed [OK]
Common Mistakes:
  • Thinking 'everysec' fsync is synchronous after every command
  • Assuming RDB snapshots block Redis for long every time
  • Believing this setup disables AOF durability
Recommended

Ready to prove it?

Pass the test and this pattern moves unknown strong while earning +1 Grip toward your certificate.

10 questions~5 mineasy hard