Databases 4 min read

Understanding Redis Persistence: RDB vs AOF Explained

Redis offers two persistence strategies—RDB snapshots and AOF command logging—each with distinct generation methods, configuration options, and recovery processes, allowing users to balance speed, safety, and data durability based on workload requirements.

Java High-Performance Architecture
Java High-Performance Architecture
Java High-Performance Architecture
Understanding Redis Persistence: RDB vs AOF Explained

Redis provides two persistence mechanisms: RDB and AOF.

RDB (Redis Database Backup)

RDB creates a compressed binary snapshot of the in‑memory dataset and saves it to disk. The snapshot can be generated manually with SAVE (blocking) or BGSAVE (non‑blocking child process), or automatically via the save configuration option, which triggers a BGSAVE when any of the defined time‑and‑change thresholds are met (e.g., 900 seconds with at least 1 change, 300 seconds with 10 changes, 60 seconds with 10 000 changes).

AOF (Append‑Only File)

AOF records every write command to a log file, similar to MySQL binlog. The file can be flushed to disk using three policies:

appendfsync always – fsync after every command (slow but safest).

appendfsync everysec – fsync every second (fast, may lose up to one second of data).

appendfsync no – rely on the operating system (fastest, least safe).

The default and recommended setting is appendfsync everysec, offering a balance between performance and durability.

Data Recovery

When Redis starts, it automatically loads an existing RDB file if present; the server blocks until the load completes. If AOF is enabled, Redis loads and replays the AOF file by reading each command, creating a simulated client, and executing the commands sequentially. When both RDB and AOF are enabled, AOF takes precedence during recovery.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

databasePersistenceBackupAOFRDB
Java High-Performance Architecture
Written by

Java High-Performance Architecture

Sharing Java development articles and resources, including SSM architecture and the Spring ecosystem (Spring Boot, Spring Cloud, MyBatis, Dubbo, Docker), Zookeeper, Redis, architecture design, microservices, message queues, Git, etc.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.