Configuring Redis Persistence: RDB and AOF for Fault Tolerance

Data loss during a Redis failure is a critical issue for businesses when task queues, sessions, or counters are stored in memory. We configure Redis persistence using RDB and AOF to protect your data. Our team delivers turnkey projects—from configuration audit to implementation and ongoing support—ensuring reliable recovery with minimal losses.

Our competencies:

Frequently Asked Questions

Latest works

  • Development of a web application for FEEDME
    Development of a web application for FEEDME
    1365
  • Development of an online store for the company FURNORO
    Development of an online store for the company FURNORO
    1330
  • B2B Advance company logo design
    B2B Advance company logo design
    776
  • Development of a web application for Enviok
    Development of a web application for Enviok
    1077
  • AIDER company logo development
    AIDER company logo development
    1022
  • CRM development for Chasseurs
    CRM development for Chasseurs
    1113

By default, Redis is an in-memory database. On restart, all data is lost. For most scenarios, that's fine if Redis is used only as a cache. But if Redis stores task queues, sessions, counters, or other data that cannot be lost—you need persistence. We've encountered this on nearly every second project: without RDB or AOF, clients lost operational data and had to manually restore from backups. For example, on a project with task queues, we lost up to 5 minutes of data between RDB snapshots, leading to duplicate orders. After implementing AOF with everysec, losses dropped to 1 second. Configuring Redis Persistence is a basic task for any production service with data durability requirements. Let's examine both mechanisms and their combined use.

There are two mechanisms: RDB (snapshots) and AOF (append-only file). They can be used individually or together. Proper configuration is the foundation of reliable recovery with at most one second of data loss.

How RDB works

RDB saves a full snapshot of the data into a binary file dump.rdb. Configuration via the save directive:

save 900 1 save 300 10 save 60 10000 

This means: save if at least 1 key changed in 900 seconds, or 10 keys in 300 seconds, or 10000 keys in 60 seconds. On restart, Redis loads the latest dump.rdb.

The main drawback of RDB is data loss between snapshots. If Redis crashes 5 minutes before the next snapshot, you lose 5 minutes of changes. This is critical on high-load projects.

According to the official Redis documentation, a snapshot is performed via fork()—a child process writes data to disk while the parent continues handling requests. During fork(), Redis may experience slight latency spikes—on a large dataset (10+ GB) this can be several seconds. Critical for low-latency applications.

Manual snapshot without blocking: BGSAVE. With blocking (for backup): SAVE.

What is AOF?

AOF writes every write command to a log file. On restart, Redis replays the entire AOF to recover data.

appendonly yes
appendfilename "appendonly.aof"
appendfsync everysec
no-appendfsync-on-rewrite no
auto-aof-rewrite-percentage 100
auto-aof-rewrite-min-size 64mb

appendfsync is the key parameter:

  • always – fsync after every command. Maximum reliability, minimum speed.
  • everysec – fsync every second. Maximum of 1 second data loss on failure. Balance of reliability and performance.
  • no – fsync determined by OS. Fast, but data loss is unpredictable.

everysec is the right choice for most cases.

AOF grows over time. auto-aof-rewrite-percentage 100 means: when the file doubles relative to its size after the last rewrite, trigger BGREWRITEAOF, which creates a compact AOF only with the current commands (without intermediate SET/DEL of the same key).

More about AOF rewriteAOF rewrite uses a child process, similar to BGSAVE, but instead of a snapshot it creates a new compact journal. During rewrite, Redis continues writing to the old AOF. After completion, the new file atomically replaces the old one. The process is controlled by auto-aof-rewrite-percentage and auto-aof-rewrite-min-size. For large files (>10 GB), manual BGREWRITEAOF may be necessary during low load hours.

Why use both mechanisms together?

When both mechanisms are enabled, on restart Redis uses AOF (more precise). RDB remains as a fast snapshot for backups.

save 900 1 appendonly yes appendfsync everysec 

This is the recommended configuration for production where data durability matters. We use this on 80% of our projects, including high-load services.

How to choose between RDB and AOF?

Compare key parameters:

Parameter RDB AOF
Format Binary snapshot Command journal
File size Compact Larger (but rewrite helps)
Data loss Between snapshots (minutes) Up to 1 sec (everysec)
Recovery speed Fast (single file) Slower (replaying commands)
Performance impact Fork + I/O at snapshot I/O per write (fsync)
Manual management BGSAVE / SAVE BGREWRITEAOF

Tailored to specific scenarios:

Scenario Recommended approach Rationale
Cache (data rebuildable) No persistence Maximum performance, no fork
Queues, sessions RDB + AOF everysec Guaranteed recovery with at most 1 second loss
Counters, analytics AOF everysec only More compact than RDB with frequent writes
Microservices with low-latency AOF everysec + disable fork Avoid latency spikes from fork

For pure cache scenario

If Redis is a pure cache and data can be warmed up on restart:

save "" appendonly no 

Disable all persistence mechanisms. Redis will be faster (no disk I/O), and fork() for snapshots won't cause latency spikes. Savings in CPU and RAM – up to 30% depending on load.

How we configure Redis Persistence end-to-end

The process takes 2 to 3 days depending on data volume and fault tolerance requirements:

  1. Load analysis and scenario mapping – determine if persistence is needed, select mechanisms.
  2. Configuration – set save intervals, AOF parameters, rewrite, fsync.
  3. Recovery testing – simulate failure, verify data recovers within expected time.
  4. Monitoring – add metrics (RDB duration, AOF rewrite, fork latency) to Prometheus/Grafana.
  5. Documentation and training – document runbook for on-call team.

What's included in the work

  • Configuring RDB and AOF via Ansible (Terraform).
  • Performance and recovery tests (results in report).
  • Monitoring: Grafana dashboards, alerts for fork latency.
  • Runbook documentation: how to check, restart, troubleshoot.
  • Team training: 1 hour online session with demonstration.

Common configuration mistakes

  • Using appendfsync always unnecessarily – causes 10x drop in IOPS.
  • Too frequent save (every 60 seconds with 10k changes) – disk overload.
  • Forgetting about AOF rewrite – file grows to tens of gigabytes.
  • Setting stop-writes-on-bgsave-error no – risk of data loss on snapshot failure.

Guarantees and experience

The cost of configuration is calculated individually based on architecture complexity. We guarantee data recovery within the specified RTO/RPO provided logs are intact. With over 5 years of Redis experience and 50+ successful production projects, we deliver reliable persistence. To evaluate your project, contact us – we'll select the optimal configuration and test it on your staging environment. Get a consultation today.

Order Redis Persistence configuration from experienced engineers – ensure your service's fault tolerance.