Database Management
Redis
Subjective
Oct 05, 2025
Compare Redis persistence options: RDB vs AOF.
Detailed Explanation
Redis offers two persistence mechanisms:
**RDB (Redis Database Backup):**
# Configuration
save 900 1 # save if 1 key changed in 900 seconds
save 300 10 # save if 10 keys changed in 300 seconds
save 60 10000 # save if 10000 keys changed in 60 seconds
# Manual snapshot
BGSAVE # background save
SAVE # blocking save
**Pros:** Compact, fast recovery, good for backups
**Cons:** Data loss possible, CPU intensive during saves
**AOF (Append Only File):**
# Configuration
appendonly yes
appendfsync everysec # fsync every second
# appendfsync always # fsync every command (slow)
# appendfsync no # let OS decide
# AOF rewrite
BGREWRITEAOF
**Pros:** Better durability, readable format
**Cons:** Larger files, slower recovery
**Hybrid Approach:**
# Use both for maximum safety
save 900 1
appendonly yes
appendfsync everysec
**When to Use:**
• RDB only: Backup scenarios, can tolerate data loss
• AOF only: Need durability, can't lose data
• Both: Production systems requiring high availability
Discussion (0)
No comments yet. Be the first to share your thoughts!
Share Your Thoughts