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 are the principles and disadvantages of AOF in Redis?

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

Share

Shulou(Shulou.com)05/31 Report--

This article mainly introduces the principles and shortcomings of AOF in Redis, which has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, let the editor take you to understand it.

AOF

We mentioned above that one of the persistence methods in rRedis is RDB.

In this article, we will talk about another way to implement it, that is, AOF.

AOF is an append log file that records only Redis write commands

The AOF log stores sequential instructions, so after the Redis downtime, the internal "repeat the old path" can achieve the purpose of data recovery.

[related recommendation: Redis video tutorial]

AOF principle

Every time we execute a write command, Redis appends the command to the AOF file

It is actually a cache summary that writes the content to memory.

So Redis needs to call the fsync function provided by Linux in real time to write the development file from the kernel cache to disk each time.

Because if we call the function in real time, we can also adjust the frequency of calling the fsync function by changing the configuration parameters.

Rewrite

If you keep appending AOF files, the log will get bigger and bigger.

So Redis implements "rewriting" internally to compress files.

First of all, because many key-value have already been state-owned enterprises, or many values are constantly updated, it is obvious that these useless data stored in the log can be optimized.

So create a child process to traverse the memory

Traverses into a new file log, so it is implemented that only the latest values need to be stored in the AOF log

We can use the command in the following figure to enable rewriting, or we can set it to execute AOF automatically.

Shortcomings of AOF

Traversing the entire memory each time will bring a lot of additional performance overhead to the system.

Recovering data each time is a long process and writing from kernel to disk each time consumes IO performance.

Thank you for reading this article carefully. I hope the article "what are the principles and shortcomings of AOF in Redis" shared by the editor will be helpful to you. At the same time, I also hope you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!

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