Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is AOF persistence in redis

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

What is AOF persistence in redis? Many novices are not very clear about this. In order to help you solve this problem, the following small series will explain it in detail for everyone. Those who have this need can come to learn. I hope you can gain something.

AOF Persistence

It is also one of the important means of Redis persistence, aof->Append Only File, only appends files, that is, this command will be appended to the end of the aof file after each request command is processed. And RDB is compressed into binary and so on.

RDB and AOF

Antirez describes the pros and cons of RDB and AOF in Redis Persistence Decryption:

An RDB is a compactly compressed binary file that represents a backup of Redis data at a point in time. Very suitable for backup, full copy and other scenarios. For example, perform bgsave backups every 6 hours and copy RDB files to remote machines or file systems for disaster recovery.

Redis loads RDB to recover data much faster than AOF

RDB data cannot be persisted in real time, while AOF data can be persisted in real time.

AOF Persistence Steps

1. Command additional steps

First, the server puts the write command to the database into the AOF buffer, and checks whether the contents of the buffer need to be written to the AOF file through the periodic function (there are generally three strategies: always, everysecond, no). These three strategies represent a balance between safety and efficiency.

2. Data restoration

Data recovery is achieved by creating a pseudo-client with no network connection and executing the commands in AOF in turn.

3. AOF rewriting

Because AOF is a record write operation command, it will lead to redundancy of files, as long as the current state of the database is re-read, so that AOF can be reduced.

The specific process is as follows:

Start by creating a child process (why not threads? Threads create locks, which leads to inefficiency. And using child processes does not block parent processes)

The parent process then creates an AOF rewrite buffer to record write commands executed during the AOF rewrite.

A write command is sent to both the AOF buffer and the AOF rewrite buffer.

Then, when the rewrite is complete, the child process sends a signal to the parent process, which appends the contents of the AOF rewrite buffer to the new AOF file and atomizes the original AOF file.

Did reading the above help you? If you still want to have further understanding of related knowledge or read more related articles, please pay attention to the industry information channel, thank you for your support.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report