Database / REDIS
What is the difference between RDB and AOF persistence?
Both write data to disk so a Redis instance can recover its dataset after a restart or crash, but they capture that data in fundamentally different forms, with different trade-offs.
| RDB | AOF |
| Point-in-time binary snapshot of the full dataset. | Append-only log of every write command, in order. |
| Faster restart, since loading one compact file is quick. | Slower restart, since the log must be replayed command by command (mitigated somewhat by AOF rewriting). |
| Can lose all writes since the last snapshot on a crash. | Can lose at most ~1 second of writes with appendfsync=everysec, or none with always. |
| Smaller file size, since it's a compacted binary snapshot. | Larger file size, though periodic rewriting keeps it from growing unbounded. |
Many production deployments run both together: RDB for fast, compact backups and quick restarts, AOF for tighter durability against a crash between snapshots. Redis merges the two on restart by preferring AOF if both are enabled, since it generally represents more recent state, falling back to RDB if AOF is disabled.
More Related questions...
