The decision matrix: RDB for snapshots with acceptable data loss, AOF for near-durability, both for maximum recovery, none for pure caches. Recovery time estimates, storage overhead, and when managed Redis changes the calculus.
P-3 — Persistence Decision Framework: RDB vs AOF vs Both vs None
Who this module is for: You have read about RDB and AOF and understand how each works. Now you need to make the right call for your specific use case — and understand why the wrong configuration is worse than no persistence at all. This module gives you the decision framework, the configuration trade-offs, and a production checklist.
The Four Configurations
Redis persistence is not a binary choice — it is a spectrum with four operating modes:
| Mode | Data Loss | Recovery Speed | Disk I/O | Use Case |
|---|---|---|---|---|
| No persistence | All data lost on restart | Instant (empty start) | None | Pure ephemeral cache |
| RDB only | Up to snapshot interval (minutes) | Fast (binary load) | Periodic bursts | Tolerable data loss, backup snapshots |
| AOF only | Up to fsync interval (≤ 1 sec) | Slow (replay commands) | Continuous | Near-durability, audit log |
| RDB + AOF | Up to fsync interval (≤ 1 sec) | Fast (RDB base + AOF delta) | Both | Maximum safety, production default |
Mode 1: No Persistence
Redis runs entirely in RAM. On crash or restart: all data is gone.
When this is correct:
- Redis is a read-through cache where the primary database is the source of truth
- Cache misses are acceptable — the application re-populates from the database
- You explicitly want no disk I/O from Redis
When this is a mistake:
- Rate limiters (a crash resets all counters)
- Session tokens (users get logged out)
- Job queues (pending jobs are lost)
- Any data that does not exist elsewhere
The mistake most engineers make: deploying a "cache" that actually stores authoritative state (sessions, tokens, locks) without persistence. When Redis restarts — deployments, OOM kills, hardware failures — data loss is silent and consequences appear minutes later.
Mode 2: RDB Only
When RDB only is correct:
- Data can tolerate loss up to the snapshot interval (minutes)
- You need fast restarts (loading 10GB of RDB takes seconds; replaying 10GB of AOF takes minutes)
- The dataset changes slowly relative to the snapshot interval
- You need periodic backups for disaster recovery regardless of AOF
The data loss window: If Redis crashes 59 seconds after the last snapshot and the save 60 10000 threshold has been met, you lose up to 59 seconds of writes. If the threshold has not been met (less than 10,000 writes), you wait for the next lower-frequency trigger.
RDB for backups: Even if you use AOF for primary persistence, keep RDB snapshots for long-term backup:
Mode 3: AOF Only
When AOF only is correct:
- You need ≤ 1 second data loss guarantee
- You do not need fast restarts (a large AOF can take minutes to replay)
- You want an audit log of all commands for compliance or debugging
Recovery time: Replaying an AOF to reconstruct 1GB of data takes seconds. Replaying an AOF for a 100GB dataset can take 10–30 minutes. During this time, Redis is not serving requests.
For large datasets, AOF-only is impractical for production deployments that need fast failover. The hybrid RDB+AOF mode (Mode 4) solves this.
Mode 4: RDB + AOF (Recommended for Production)
With aof-use-rdb-preamble yes, AOF rewrite creates a file that starts with an RDB snapshot followed by incremental AOF commands:
[RDB snapshot at time T] [AOF commands from T to now]
On restart:
- Redis loads the RDB preamble (fast binary load)
- Redis replays only the AOF delta since the snapshot (small, fast)
- Ready to serve in seconds even for large datasets
Sign in to keep reading
The rest of this module is free — sign in with Google to unlock it and track your progress.
Sign in & RegisterDiscussion
0Join the discussion