Persistence refers to the storage of data to disks at regular intervals to prevent data loss. This ensures that if a Tair (Redis OSS-compatible) instance stops responding or restarts, data can be restored from the persistent files on disks. Tair (Redis OSS-compatible) provides the Redis Database (RDB), append-only file (AOF), and Tair-Binlog persistence policies to meet the backup and restoration requirements in various scenarios.
Persistence policies
Tair (Redis OSS-compatible) supports the following persistence policies:
RDB persistence
RDB persistence creates snapshots of the data stored in Redis at specified intervals, and saves the snapshots to disks in the form of RDB files. This way, data persistence is implemented. RDB files are small in size and easy to migrate. You can use RDB files to back up or migrate data of a specified point in time.
When open source Redis generates RDB files, operations in progress may be blocked. The blocking time varies based on the total amount of data in the instance. Tair (Redis OSS-compatible) optimizes the persistence mechanism and implements non-blocking backup. This optimization allows instance backup operations to occur without affecting client requests.
By default, Tair (Redis OSS-compatible) instances are configured to back up data automatically once a day. You can modify the automatic backup policy based on your business requirements or manually create a temporary backup.
AOF persistence
AOF persistence logs all write operations received by the server, such as SET. These operations can then be replayed again at server startup, reconstructing the original dataset.
As the number of entries in an AOF grows, Redis starts an AOF rewrite process to reorganize the AOF when the AOF reaches a specific size. This process reduces the disk usage of the AOF and enhances the efficiency of data restoration. However, AOF rewrite can incur some performance overhead for write operations.
By default, AOF persistence is enabled for Tair (Redis OSS-compatible) instances. The AOF persistence policy is AOF_FSYNC_EVERYSEC and cannot be changed. Redis performs an fsync operation every second as per the policy to flush write commands from the AOF buffer to disks. This process is also referred to as AOF flushing. The AOF_FSYNC_EVERYSEC policy has little impact on the performance of Redis while also significantly reducing the risk of data loss in the event of an accident.
Tair-Binlog
Tair (Enterprise Edition) DRAM-based instances not only support the preceding two persistence policies, but also optimizes the AOF persistence mechanism to implement AOF incremental archiving. After optimization, AOFs can be archived incrementally to prevent performance degradation caused by AOF rewrite. Incremental archiving also allows data in an instance or a key to be restored to a point in time accurate to the second as this method saves each write operation and its timestamp. This data restoration process is called point-in-time recovery (PITR). For more information, see Use data flashback to restore data by point in time.
Backup and restoration solutions
Tair (Redis OSS-compatible) implements data backup and restoration based on RDB persistence, AOF persistence, and AOF incremental archiving.
Category | Solution | Description |
Data backup | Tair (Redis OSS-compatible) supports data persistence. Instance data is automatically backed up according to the default backup policy (based on RDB). You can modify the automatic backup policy based on your business requirements or manually create a temporary backup. | |
Backup files can be retained for 7 days. If you want to retain backup files for a longer period of time, you can download the backup files to your computer. For example, you may want to retain backup files for a longer period of time due to regulatory or information security requirements. | ||
Data restoration | Tair (Redis OSS-compatible) allows you to create an instance from a specified backup set. The data in the new instance is the same as that in the backup set. This feature is suitable for scenarios such as data restoration, quick workload deployment, and data verification. | |
After you enable the data flashback feature (based on AOF), you can restore data of an instance to a specified point in time accurate to the second. This feature minimizes data loss caused by accidental operations and is suitable for scenarios in which data is frequently restored. Note This feature is available only for Tair (Enterprise Edition) DRAM-based instances. |