Bird
Raised Fist0
Redisquery~5 mins

Combined RDB + AOF in Redis

Choose your learning style10 modes available
Introduction
Using both RDB and AOF together helps keep your data safe and recover it quickly if Redis stops unexpectedly.
You want fast recovery after a crash but also want to save data regularly.
You need a backup that is compact and easy to load.
You want to minimize data loss by saving changes often.
You want to combine quick startup with durability.
You want to protect your data from power failures and software crashes.
Syntax
Redis
appendonly yes
appendfilename "appendonly.aof"
rdbcompression yes
save 900 1
save 300 10
save 60 10000
appendonly yes enables AOF persistence.
save lines configure RDB snapshots at intervals.
Examples
This config enables both AOF and RDB. RDB snapshots save every 900 seconds if at least 1 key changed, every 300 seconds if 10 keys changed, and every 60 seconds if 10000 keys changed.
Redis
appendonly yes
appendfilename "appendonly.aof"
rdbcompression yes
save 900 1
save 300 10
save 60 10000
This disables AOF and uses only RDB snapshots.
Redis
appendonly no
save 900 1
save 300 10
This enables AOF with syncing every second and disables RDB snapshots.
Redis
appendonly yes
appendfsync everysec
save ""
Sample Program
This configuration file enables both RDB and AOF persistence in Redis. It saves snapshots periodically and logs every write operation to the AOF file.
Redis
# redis.conf example
appendonly yes
appendfilename "appendonly.aof"
rdbcompression yes
save 900 1
save 300 10
save 60 10000
OutputSuccess
Important Notes
Using both RDB and AOF together gives you fast recovery and minimal data loss.
RDB snapshots are compact but happen less often.
AOF logs every change but can be larger and slower to load.
Redis loads AOF first by replaying commands to restore the latest state, falling back to RDB if AOF is corrupted.
Summary
Combined RDB + AOF persistence protects your data well.
RDB provides fast startup with periodic snapshots.
AOF provides durability by logging every write operation.

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