Redis appendonly Explained: Understanding AOF Persistence

Published: 2026-07-17

Introduction

The appendonly directive controls whether Redis uses Append Only File (AOF) persistence.

By default, Redis stores data in memory. If the server restarts unexpectedly, all in-memory data may be lost unless persistence is enabled.

When AOF is enabled, Redis records every write operation to a log file. During startup, Redis replays these operations to rebuild the dataset.

This guide explains how appendonly works, its advantages and disadvantages, and when it should be enabled.

Default Value

appendonly no

By default, AOF persistence is disabled.

Redis will rely on other persistence options, such as RDB snapshots, if configured.

Syntax

appendonly yes

or

appendonly no

How AOF Works

When AOF is enabled:

A client sends a write command.

Redis updates the in-memory dataset.

The command is appended to the AOF file.

After a restart, Redis replays the AOF file to restore the data.

Unlike RDB snapshots, AOF records individual write operations instead of saving periodic snapshots.

Advantages

Enabling AOF provides several benefits.

Better durability.

Lower risk of data loss.

Automatic recovery after a restart.

Human-readable command log.

Suitable for production systems requiring higher reliability.

Disadvantages

AOF also has some trade-offs.

Larger disk usage.

Slightly slower write performance.

Longer startup time for very large AOF files.

Requires periodic rewriting to reduce file size.

Enable AOF

Edit the Redis configuration file.

sudo nano /etc/redis.conf

Locate:

appendonly no

Change it to:

appendonly yes

Save the file and restart Redis.

sudo systemctl restart redis

Verify the Configuration

Run:

redis-cli CONFIG GET appendonly

Example output:

1) "appendonly"

2) "yes"

AOF File Location

The AOF file is typically stored in the Redis working directory.

Example:

/var/lib/redis/

Common filenames include:

appendonly.aof

or, in newer Redis versions using multi-part AOF:

appendonlydir/

The exact location depends on the dir configuration.

Runtime Configuration

Enable AOF without restarting.

redis-cli CONFIG SET appendonly yes

Disable AOF.

redis-cli CONFIG SET appendonly no

Remember to update redis.conf if the change should persist after a restart.

AOF vs RDB

| Feature        | AOF              | RDB                          |
| -------------- | ---------------- | ---------------------------- |
| Storage method | Logs every write | Periodic snapshots           |
| Data loss      | Very low         | Depends on snapshot interval |
| Startup speed  | Slower           | Faster                       |
| Disk usage     | Higher           | Lower                        |
| Durability     | Better           | Moderate                     |

Many production deployments enable both AOF and RDB to balance durability and recovery speed.

When Should You Enable appendonly?

Enable AOF if:

Data persistence is important.

The application cannot tolerate losing recent writes.

Redis stores business-critical information.

Recovery after crashes is a priority.

You may leave AOF disabled if:

Redis is used only as a temporary cache.

Cached data can be regenerated easily.

Maximum write performance is the primary goal.

Common Mistakes

Assuming AOF Prevents All Data Loss

Although AOF greatly reduces data loss, some recent writes may still be lost depending on the appendfsync policy.

Ignoring Disk Space

AOF files grow over time and require sufficient disk capacity.

Forgetting AOF Rewrite

Redis periodically rewrites the AOF file to remove redundant commands and reduce file size.

Best Practices

Enable AOF for production systems that require persistence.

Combine AOF with RDB snapshots for improved recovery options.

Monitor disk usage regularly.

Keep regular backups of persistent data.

Choose an appropriate appendfsync policy based on your durability and performance requirements.

Related Articles

Redis Explained

Redis maxmemory Explained

Redis maxmemory-policy Explained

Redis save Explained

Redis appendfsync Explained

Conclusion

The appendonly directive enables Redis AOF persistence, allowing write operations to be recorded and replayed after a restart. While AOF introduces some additional disk usage and write overhead, it provides significantly better durability than running Redis entirely in memory.

For most production environments where data integrity matters, enabling AOF—often alongside RDB snapshots—is considered a best practice.

Explore More

Technology Guides →

Redis Persistence Explained: RDB vs AOF and Data Durability

Redis save Explained: Configuring RDB Snapshots for Data Persistence

Redis databases Explained: Understanding Logical Databases in Redis

Redis protected-mode Explained: Understanding Redis Security Protection

Southeast Asia Insights →

Why Do Thai People Eat Outside So Often? Understanding Thailand's Unique Food Culture

Why Do People in Southeast Asia Love Iced Drinks? The Climate, Culture, and Science Explained

Chinese vs Thai Work Culture: Understanding the Differences in Workplace Values

Northern vs Southern Chinese Business Culture: Key Differences Explained