7 questions foundWhat is RDB persistence in Redis, and how does it work?
Beginner RDB persistence periodically saves a complete point in time snapshot of your entire dataset to a single compact file on disk, based on configured save rules, such as saving automatically if a certain number of changes have been made within a given time period, giving you a compact backup you can use to restore your data if Redis restarts.
SAVE -- creates an RDB snapshot immediately
BGSAVE -- creates a snapshot in the background
CONFIG SET save '900 1'
Real-world example A company configures Redis to automatically save an RDB snapshot every fifteen minutes if at least one key has changed, giving them a reasonably recent backup without needing to save constantly and impact performance.
Common follow-ups: What is the difference between SAVE and BGSAVE?;How much data could potentially be lost if Redis crashes right before a scheduled RDB save?
Redis Backup & Disaster Recovery;Redis Architecture & Installation
What is AOF, or append only file, persistence, and how does it differ from RDB snapshots?
Beginner AOF persistence logs every write operation to a file as it happens, rather than periodically saving the entire dataset at once like RDB, meaning it can offer much better durability with less potential data loss since nearly every write is recorded individually, though the resulting log file can grow significantly larger than an equivalent RDB snapshot.
CONFIG SET appendonly yes
CONFIG SET appendfsync everysec
Real-world example A financial application enables AOF persistence to minimize the risk of losing recent transactions, accepting the larger file size in exchange for the much stronger durability guarantee it provides over RDB snapshots alone.
Common follow-ups: What does the appendfsync setting control, and what are the different options?;Can RDB and AOF persistence be used together at the same time?
Redis Backup & Disaster Recovery;Transactions & ACID
What are the different appendfsync options available for AOF persistence, and how do they balance durability against performance?
Intermediate The always option writes and flushes to disk after every single write command, providing the strongest durability but the slowest performance, everysec flushes to disk once per second, offering a reasonable balance most applications choose by default, and no relies on the operating system to decide when to flush, offering the best performance but the weakest durability guarantee.
CONFIG SET appendfsync everysec -- a common balanced default
Real-world example A team evaluating their durability requirements chooses the everysec setting as a reasonable balance, accepting the small risk of losing up to one second of writes during a crash in exchange for meaningfully better performance than the always option.
Common follow-ups: How much data could actually be lost with the everysec setting during a crash?;When would the always setting actually be necessary despite its performance cost?
Redis Backup & Disaster Recovery;Redis Performance Tuning & Benchmarking
What is AOF rewriting, and why is it necessary as an append only file grows over time?
Intermediate AOF rewriting compacts the append only file by rebuilding it from the current in memory dataset rather than the full history of every write command ever issued, removing redundant operations like multiple updates to the same key, which prevents the file from growing indefinitely and keeps both its size and the time needed to reload it from disk more reasonable over time.
BGREWRITEAOF -- triggers a background AOF rewrite
CONFIG SET auto-aof-rewrite-percentage 100
Real-world example A busy Redis instance automatically triggers an AOF rewrite once its append only file has grown to double its size since the last rewrite, keeping the file from becoming unmanageably large over weeks of continuous operation.
Common follow-ups: Does AOF rewriting happen automatically, or does it need to be triggered manually?;What happens to write operations that occur while a rewrite is actively in progress?
Redis Performance Tuning & Benchmarking;Redis Architecture & Installation
How would you design a persistence strategy that combines both RDB and AOF to get the benefits of both approaches?
Advanced You would enable both RDB snapshots for fast, compact full backups useful for quick restores and off site backup storage, and AOF for stronger durability during normal operation, configuring Redis to prefer loading from AOF on restart since it typically has less potential data loss, while still keeping RDB snapshots available as an additional safety net and for easier data portability.
CONFIG SET save '900 1'
CONFIG SET appendonly yes
CONFIG SET appendfsync everysec
Real-world example A company running a critical Redis instance enables both RDB and AOF together, getting fast periodic snapshots for easy backup and disaster recovery purposes while also benefiting from AOF's stronger protection against data loss during normal operation.
Common follow-ups: Which persistence method does Redis prefer to load from if both are present after a restart?;What are the tradeoffs of running both persistence methods simultaneously in terms of disk usage and performance?
Redis Backup & Disaster Recovery;Redis Architecture & Installation
What happens during Redis startup regarding data loading, and how does the choice between RDB and AOF affect startup time for a large dataset?
Advanced When Redis starts, it loads its dataset from either the AOF file or the RDB snapshot depending on your configuration, and since AOF files can be significantly larger and require replaying potentially many individual write operations, startup time using AOF can be noticeably slower for very large datasets compared to loading a single compact RDB snapshot directly into memory.
-- Check current persistence configuration affecting startup behavior
CONFIG GET appendonly
CONFIG GET dir
Real-world example A team notices their Redis instance takes significantly longer to restart after enabling AOF for a very large dataset, and mitigates this by ensuring AOF rewrites happen regularly to keep the file as compact as possible.
Common follow-ups: How do you measure and test Redis startup time for your specific dataset size?;Are there configuration options to speed up AOF loading during startup?
Redis Architecture & Installation;Redis Performance Tuning & Benchmarking
What happens if Redis's persistence files, whether RDB or AOF, become corrupted, and how would you attempt to recover?
Intermediate For a corrupted RDB file, you generally need to restore from an earlier valid backup since there is limited built-in repair capability, while for a corrupted AOF file, Redis provides a redis-check-aof tool that can attempt to fix the file by truncating it at the point where corruption begins, potentially losing only the most recent, damaged portion of the log rather than the entire file.
redis-check-aof --fix appendonly.aof
Real-world example A team recovers from a partially corrupted AOF file caused by an unexpected server crash using the redis-check-aof repair tool, losing only the last few seconds of writes rather than the entire dataset.
Common follow-ups: How often should backup files be tested to confirm they are not corrupted?;What steps can reduce the risk of persistence file corruption happening in the first place?
Redis Backup & Disaster Recovery;Redis Architecture & Installation