Persistence in Redis means saving data to disk so it is not lost if the server restarts or crashes.
Click to reveal answer
beginner
How does enabling persistence affect Redis performance?
Enabling persistence can slow down Redis because saving data to disk takes extra time and resources.
Click to reveal answer
intermediate
What are the two main persistence methods in Redis?
The two main methods are RDB (snapshotting) and AOF (append-only file). RDB saves snapshots periodically, AOF logs every write operation.
Click to reveal answer
intermediate
Why might you choose RDB over AOF for persistence?
RDB is faster and uses less disk space but can lose recent data if Redis crashes between snapshots.
Click to reveal answer
intermediate
What is the trade-off when using AOF persistence?
AOF provides better data safety by logging every change but can slow Redis down and use more disk space.
Click to reveal answer
Which Redis persistence method saves data by taking snapshots at intervals?
ABoth RDB and AOF
BAOF
CNone
DRDB
✗ Incorrect
RDB saves snapshots of the dataset at specified intervals.
What is a downside of enabling persistence in Redis?
AIt can slow down Redis performance
BIt deletes data automatically
CIt disables network access
DIt uses no disk space
✗ Incorrect
Persistence requires writing data to disk, which can slow down Redis.
Which persistence method logs every write operation in Redis?
ARDB
BAOF
CSnapshotting
DNone
✗ Incorrect
AOF logs every write command to a file for better durability.
If you want faster Redis performance and can tolerate some data loss, which persistence method is better?
AAOF
BBoth are equal
CRDB
DNo persistence
✗ Incorrect
RDB is faster but may lose recent data between snapshots.
What is the main benefit of using AOF persistence?
ABetter data safety with less data loss
BUses less disk space
CFaster writes
DNo performance impact
✗ Incorrect
AOF logs every write, so it can recover more recent data after a crash.
Explain the trade-off between persistence and performance in Redis.
Think about how saving data affects speed and safety.
You got /4 concepts.
Describe when you might choose RDB persistence over AOF in Redis.
Consider performance needs and data safety.
You got /4 concepts.
Practice
(1/5)
1. Which Redis persistence method saves data at specific time intervals, balancing durability and performance?
easy
A. No persistence
B. AOF logging
C. RDB snapshots
D. In-memory only
Solution
Step 1: Understand Redis persistence options
Redis offers RDB snapshots and AOF logging for persistence.
Step 2: Identify method saving data at intervals
RDB snapshots save data periodically, while AOF logs every write.
Final Answer:
RDB snapshots -> Option C
Quick Check:
Persistence by snapshots = RDB snapshots [OK]
Hint: Snapshots save periodically, logs save every write [OK]
Common Mistakes:
Confusing AOF with snapshots
Thinking no persistence saves data
Assuming in-memory is persistent
2. Which Redis configuration option enables Append Only File (AOF) persistence?
easy
A. appendonly yes
B. appendonly no
C. save 900 1
D. stop-writes-on-bgsave-error no
Solution
Step 1: Identify AOF enabling option
The option to enable AOF is 'appendonly yes'.
Step 2: Differentiate from snapshot options
'save 900 1' relates to RDB snapshots, not AOF.
Final Answer:
appendonly yes -> Option A
Quick Check:
Enable AOF = appendonly yes [OK]
Hint: Enable AOF with 'appendonly yes' in config [OK]
Common Mistakes:
Using 'appendonly no' disables AOF
Confusing 'save' with AOF setting
Misreading unrelated config options
3. Given Redis configured with RDB snapshots every 60 seconds and AOF enabled with 'appendfsync everysec', what is the maximum data loss if Redis crashes?
medium
A. Up to 1 second of data loss
B. Up to 60 seconds of data loss
C. No data loss
D. Up to 5 minutes of data loss
Solution
Step 1: Understand RDB snapshot interval
Snapshots save every 60 seconds, so up to 60 seconds loss if using RDB only.
Step 2: Consider AOF 'appendfsync everysec'
This setting syncs AOF every second, limiting loss to up to 1 second.
Step 3: Combine effects
With both RDB and AOF enabled, Redis prioritizes AOF for recovery of recent writes, so maximum data loss is 1 second.
Final Answer:
Up to 1 second of data loss -> Option A
Quick Check:
AOF everysec = up to 1s loss [OK]
Hint: Max loss = AOF fsync interval when AOF enabled [OK]
Common Mistakes:
Thinking RDB interval dominates with AOF enabled
Ignoring AOF sync policy
Confusing 'everysec' with immediate sync
4. You configured Redis with 'appendonly yes' but notice no AOF file is created. What is the most likely cause?
medium
A. AOF file is corrupted
B. RDB snapshots disabled
C. Disk is full
D. Redis was not restarted after config change
Solution
Step 1: Check if config changes take effect immediately
Changing 'appendonly yes' requires Redis restart to activate.
Step 2: Rule out other causes
Disk full or corruption would cause errors, snapshots don't affect AOF creation.
Final Answer:
Redis was not restarted after config change -> Option D
Quick Check:
Config changes need restart [OK]
Hint: Restart Redis after enabling AOF [OK]
Common Mistakes:
Assuming snapshots affect AOF file
Ignoring need to restart Redis
Blaming disk issues without checking
5. You want Redis to minimize data loss but can tolerate some performance cost. Which configuration best fits this need?
hard
A. Enable RDB snapshots every 15 minutes and disable AOF
B. Enable AOF with 'appendfsync everysec' and RDB snapshots every 5 minutes
C. Enable AOF with 'appendfsync always' and disable RDB snapshots
D. Disable both AOF and RDB snapshots for max speed
Solution
Step 1: Understand data loss vs performance trade-off
'appendfsync always' is safest but slowest; 'everysec' balances safety and speed.
Step 2: Combine AOF and snapshots for better durability
Using both reduces data loss and improves recovery options.
Step 3: Evaluate options
Enable AOF with 'appendfsync everysec' and RDB snapshots every 5 minutes balances minimal data loss with acceptable performance cost.
Final Answer:
Enable AOF with 'appendfsync everysec' and RDB snapshots every 5 minutes -> Option B