Module P-3·16 min read

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.

JJS
Written by Jatin Jain Saraf · Senior Software Engineer

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:

ModeData LossRecovery SpeedDisk I/OUse Case
No persistenceAll data lost on restartInstant (empty start)NonePure ephemeral cache
RDB onlyUp to snapshot interval (minutes)Fast (binary load)Periodic burstsTolerable data loss, backup snapshots
AOF onlyUp to fsync interval (≤ 1 sec)Slow (replay commands)ContinuousNear-durability, audit log
RDB + AOFUp to fsync interval (≤ 1 sec)Fast (RDB base + AOF delta)BothMaximum safety, production default

Mode 1: No Persistence

text

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

text

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:

text

Mode 3: AOF Only

text

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.


text

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:

  1. Redis loads the RDB preamble (fast binary load)
  2. Redis replays only the AOF delta since the snapshot (small, fast)
  3. 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 & Register

Discussion

0

Join the discussion

Loading comments...

© 2026 Jatin Jain Saraf (JJS). All rights reserved.