Bird
Raised Fist0
Redisquery~3 mins

Why Combined RDB + AOF in Redis? - Purpose & Use Cases

Choose your learning style10 modes available
The Big Idea

What if your data vanished just because you waited too long to save it?

The Scenario

Imagine you run a busy store and keep track of sales on paper. Every hour, you copy all sales into a big book. But if the store closes suddenly, you lose all sales since the last copy.

The Problem

Copying all sales manually every hour is slow and misses recent sales if a sudden event happens. Also, writing every sale on paper takes time and can cause mistakes or lost data.

The Solution

Combined RDB + AOF in Redis saves a full snapshot occasionally (RDB) and logs every change (AOF). This way, you get fast recovery from snapshots and no lost data from recent changes.

Before vs After
✗ Before
save_every_hour()
log_changes_manually()
✓ After
redis.conf: save snapshots + appendonly yes
What It Enables

You can recover your data quickly and safely without losing recent updates, even if the system crashes unexpectedly.

Real Life Example

An online game saves player scores every few minutes (RDB) and records every move instantly (AOF), so no progress is lost if the server restarts.

Key Takeaways

Manual backups miss recent changes and are slow.

RDB snapshots save full data fast but can lose recent updates.

AOF logs every change to prevent data loss.

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