This page provides an overview of AOF persistence for Memorystore for Valkey.
Memorystore for Valkey also supports RDB persistence, but you must choose either the AOF or RDB persistence mode, because both can't be enabled at the same time. For information about choosing between the two persistence modes, see Persistence overview.
For the best possible instance availability, we recommend using a highly available instance in addition to enabling persistence.
To learn how to enable, disable, and monitor AOF persistence, see Manage persistence.
AOF persistence overview
The AOF persistence mode prioritizes data durability. It durably stores data by recording every write command to a log file called the AOF file. If a system failure or restart occurs, the server replays AOF file commands sequentially to restore your data. Unlike RDB persistence, AOF persistence can't be paused.
Sync setting
The sync setting (appendfsync
) for the AOF persistence mode determines how
often the cached data in memory is saved to durable storage. We recommend
keeping the sync setting at 1 second, which is the default. Syncing every second
provides the best compromise between instance performance, and data durability.
Before the AOF logs are saved to durable storage, they are stored in memory by the operating system, and if a system failure or restart occurs during this time, the writes in memory can be lost. The sync setting lets you choose how often data is saved to durable storage, and provides the following options:
always
- This option saves data to storage for every write.everysec
- This option saves data to storage every second.no
- This option relies on the operating system to flush data to disk on its own schedule, which typically happens every 30 seconds.
Choosing to sync for every write provides the best data durability, however this comes with a performance tradeoff. We recommend syncing every second, which provides both good data durability and performance.