Bird
Raised Fist0
Redisquery~20 mins

Combined RDB + AOF in Redis - Practice Problems & Coding Challenges

Choose your learning style10 modes available
Challenge - 5 Problems
🎖️
Redis Persistence Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why use both RDB and AOF in Redis?
Redis supports two persistence methods: RDB snapshots and AOF logs. What is the main advantage of combining both methods for data durability?
AIt provides faster recovery by loading a snapshot and then replaying recent commands from the AOF log.
BIt reduces memory usage by storing data only in RDB files and ignoring AOF logs.
CIt disables data persistence to improve performance during peak loads.
DIt automatically compresses data to save disk space without any data loss.
Attempts:
2 left
💡 Hint
Think about how snapshots and logs complement each other in restoring data.
❓ query_result
intermediate
2:00remaining
Result of Redis persistence config
Given this Redis configuration snippet:
save 900 1
save 300 10
save 60 10000
appendonly yes
aof-use-rdb-preamble yes

What does enabling aof-use-rdb-preamble yes do when Redis restarts?
ARedis ignores the RDB snapshot and loads only the AOF file.
BRedis loads the RDB snapshot first, then replays the AOF commands recorded after the snapshot.
CRedis disables AOF and uses only RDB snapshots for persistence.
DRedis merges RDB and AOF files into a single file for faster loading.
Attempts:
2 left
💡 Hint
Consider how the RDB preamble affects the AOF loading process.
📝 Syntax
advanced
2:00remaining
Identify the invalid Redis config line
Which of the following Redis configuration lines is invalid when combining RDB and AOF persistence?
Asave 900 1
Bappendonly yes
Caof-use-rdb-preamble maybe
Dappendfsync everysec
Attempts:
2 left
💡 Hint
Check the allowed values for aof-use-rdb-preamble.
❓ optimization
advanced
2:00remaining
Optimizing Redis restart time with combined persistence
You want to minimize Redis restart time while ensuring no data loss. Which configuration change best achieves this when using both RDB and AOF?
AEnable <code>aof-use-rdb-preamble yes</code> and set <code>appendfsync everysec</code>.
BEnable RDB snapshots only and disable AOF.
CDisable RDB snapshots and rely only on AOF with <code>appendfsync always</code>.
DSet <code>appendfsync no</code> and rely on RDB snapshots every 60 seconds.
Attempts:
2 left
💡 Hint
Think about how the RDB preamble and AOF sync frequency affect restart and durability.
🔧 Debug
expert
2:00remaining
Why does Redis fail to load combined persistence?
A Redis server is configured with:
appendonly yes
aof-use-rdb-preamble yes
save 900 1

On restart, Redis fails with an error about AOF file corruption. Which is the most likely cause?
ARedis does not support using RDB snapshots and AOF together.
BThe <code>aof-use-rdb-preamble</code> option must be set to <code>no</code> when <code>appendonly yes</code> is enabled.
CThe <code>save</code> directive conflicts with <code>appendonly yes</code> causing a syntax error.
DThe AOF file was manually edited and the RDB preamble is corrupted.
Attempts:
2 left
💡 Hint
Consider what happens if the AOF file is manually changed.

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