Redis persistence

  • Compare the copies available after process failure, host loss and an application error.
100%
Serving hostsPrimary diskSeparate recovery locationRestart, failover and restore use different copiesClient / applicationStored dataReplicationwriteasync streamsnapshotappend / fsynccopy completed RDBA successful write reply confirms execution on the primary. The chosen replication and fsync policy determines which copies can already recover it.ApplicationApplies commands in memory and streams replication. Local RDB and AOF persistence have independent storage costs and write windows.Redis primaryIn-memory statePromotion serves the state received by that replica. A replica also follows normal deletions and erroneous writes.ReplicaIndependent hostA snapshot captures the dataset as of its fork point. Completion and backup transfer happen later.RDB filePoint-in-time imageThe manifest identifies the base and incremental files. An AOF rewrite compacts the base while new changes are captured.AOF file setBase + incrementsKeep complete, consistent recovery sets off the primary storage failure boundary. Retain a known-good version and rehearse restore into an isolated instance.Versioned backupRestore drillwriteasync streamsnapshotappend / fsynccopy completed RDB

Select a component to trace its direct connections. Drag to pan · Ctrl + wheel or pinch to zoom.

  • RDB captures the keys at one point in time. The append-only file (AOF) records changes. With both enabled, a restart on intact storage rebuilds from the AOF.
  • With the example’s once-per-second disk flush, a successful write may still be in memory when the host fails. A replica can take over with the writes it received.
  • An accidental delete also reaches replicas. A separately retained RDB from before the delete gives the operator a point to restore and compare with later writes.
  • Failover selects a replica. A same-node restart loads enabled local persistence. Recovery from a bad write can require a backup taken before the incident.
  • The example backs up completed RDBs separately. Restoring from a multi-part AOF requires the matching manifest and all files it references.
Redis persistence

Redis persistence

Redis Open Source 7.2 architecture

Choose recovery points

Copy What it contains Recovery cost
RDB Dataset at a completed snapshot’s fork point Compact backup and relatively fast load. Later writes may be absent.
AOF with everysec Base file plus incremental commands, selected by the manifest Usually a smaller loss window. Background fsync, rewrites and replay consume storage resources.
Asynchronous replica Changes that reached a second process Can be promoted after primary loss. An application error can replicate to it too.
  • The configuration enables both RDB and AOF. A restart with both enabled uses AOF to reconstruct the dataset. Put each node’s persistence on its own durable volume.
  • The illustrative save rule requires both 300 seconds and 100 changes. It sets a trigger, without promising a successful snapshot at every five-minute boundary.
Snapshot and append-log policyconf
# Illustrative persistent-node fragment for Redis Open Source 7.2+.
# Give each node its own writable persistent volume and enough free space
# for both an old and a new file set during a rewrite.
dir /data
dbfilename dump.rdb
save 300 100
appendonly yes
appenddirname appendonlydir
appendfsync everysec

# 'save 300 100' requires BOTH elapsed time and sufficient changes.
# Copy complete, consistent recovery sets to an independent backup location.

Read the acknowledgement precisely

  • An ordinary success reply under everysec can arrive before the write is fsynced. In typical conditions a crash may lose about a second of writes. Storage stalls, disk loss and restore from an older backup have different recovery windows.
  • WAIT counts replica acknowledgments for prior writes on that client connection. WAITAOF, available in Redis 7.2, can wait for preceding writes to reach local and/or replica AOF fsync. Check the returned counts; a timeout leaves the write outcome to reconcile.
  • Waiting for additional copies increases tail latency. Automatic failover can still choose a different eligible replica. Define the application’s acceptable lost-work and duplicate-work limits separately.

Test three failures

Scenario Recovery evidence
Process restart on intact storage Restore the selected local file set on an isolated instance, then inspect a known write marker and loading time.
Primary host loss Check the promoted replica’s last marker, client rediscovery and the fate of ambiguous writes.
Bad bulk update or lost volume Restore an independently retained known-good version, validate application invariants and reconcile changes after that point.
  • For multi-part AOF, capture a consistent manifest and the matching base/increment files as a set. RDB backups use completed snapshot files. Measure rewrite disk headroom and copy-on-write memory under actual write load.
  • For a sharded dataset a single-node backup covers that node’s slots. Coordinate recovery points across shards when application invariants span them.