In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-06 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces what is the difference between rdb and aof of redis. It is very detailed and has certain reference value. Friends who are interested must finish it!
The difference between persistent RDB and AOF
RDB persistence means that the snapshot of the dataset in memory is written to disk within a specified time interval. The actual operation is a child process of fork, which first writes the dataset to a temporary file, and then replaces the previous file and stores it with binary compression.
RDB persists all key-value pairs in the key space (including the data in the expired dictionary) and saves them in binary form, which conforms to the rdb file specification and will be handled differently according to different data types.
AOF persistence records every write and delete operation processed by the server in the form of log, query operation is not recorded, it is recorded in the form of text, and you can open the file to see the detailed operation record.
AOF persists all write commands executed by the redis server to record the database state, and the commands are stored in the aof_buf buffer before writing.
Pros and cons of persistent RDB and AOF:
What are the advantages of RDB?
1) once you use this approach, your entire Redis database will contain only one file, which is perfect for file backup. For example, you might plan to archive data for the last 24 hours every hour, as well as data for the last 30 days once a day. Through this backup strategy, in the event of a catastrophic failure of the system, we can recover very easily.
2) RDB is a very good choice for disaster recovery. Because we can easily compress a single file and then transfer it to other storage media.
3), maximize performance. For the Redis service process, at the beginning of persistence, the only thing it needs to do is to fork the child process, and then the child process completes the persistence work, which can greatly prevent the service process from performing IO operations.
4) compared with the AOF mechanism, if the dataset is large, the startup efficiency of RDB will be higher.
What are the disadvantages of RDB?
1)。 If you want to ensure high availability of data, that is, to avoid data loss as much as possible, then RDB will not be a good choice. Because once the system goes down before timing persistence, data that has not been written to disk before will be lost.
2)。 Because RDB assists in data persistence through the help child process, if the dataset is large, it may cause the entire server to go out of service for hundreds of milliseconds, or even 1 second.
What are the advantages of AOF?
1) this mechanism can bring higher data security, that is, data persistence. Three synchronization strategies are provided in Redis, that is, synchronization per second, synchronization per modification, and async. In fact, synchronization per second is also done asynchronously, and its efficiency is also very high. The only difference is that once the system downtime occurs, then the modified data within this second will be lost. Every time we modify synchronization, we can think of it as synchronous persistence, that is, every data change that occurs is immediately recorded to disk. It can be predicted that this approach is the least efficient. As for non-synchronization, needless to say, I think everyone can understand it correctly.
2) because this mechanism uses append mode to write log files, even if there is a downtime in the writing process, it will not destroy the contents that already exist in the log files. However, if we only write half the data this time and the system crashes, don't worry, we can use the redis-check-aof tool to help us solve the data consistency problem before the next startup of Redis.
3) if the log is too large, Redis can automatically enable the rewrite mechanism. That is, Redis constantly writes the modified data to the old disk file in append mode, and Redis also creates a new file to record which modification commands were executed during this period. Therefore, data security can be better guaranteed when rewrite switching is carried out.
4) AOF contains a clearly formatted and easy-to-understand log file for recording all changes. In fact, we can also complete the reconstruction of the data through this file.
What are the disadvantages of AOF?
1) for the same number of datasets, AOF files are usually larger than RDB files. RDB recovers large datasets faster than AOF does.
2) according to the different synchronization strategies, AOF tends to be slower than RDB in running efficiency. In short, the efficiency of synchronization per second policy is relatively high, and the efficiency of synchronization disable policy is as efficient as that of RDB.
The standard of choice between the two is to see whether the system is willing to sacrifice some performance for higher cache consistency (aof), or is willing to write frequently, do not enable backup in exchange for higher performance, and then do backup (rdb) when save is run manually. Rdb is even more eventually consistent. However, the production environment is actually more of a combination of the two.
These are all the differences between redis's rdb and aof. Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.