0
0
Redisquery~10 mins

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

Choose your learning style9 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.