Current location - Health Preservation Learning Network - Healthy weight loss - Difference between rdb and redis persistent aof
Difference between rdb and redis persistent aof
The data in Redis is stored in computer memory. If we don't configure it, the data will be lost after restarting Redis. Here we need the persistence technology in Redis, which stores the data in the disk, and can still get the data from the disk after restarting Redis, so as to achieve the effect of persistence.

What is the difference between RDB and AOF?

RDB persistence is to write snapshots of data sets in memory to disk within a specified time interval. The actual operation process is that there is a fork subprocess. First, the data set is written into a temporary file, and then the previous file is replaced after successful writing, and the data set is compressed and stored in binary.

The persistence of AOF is to record every write and delete operation processed by the server in the form of a log. The query operation will not be recorded, but recorded in the form of text, and you can open the file to view the detailed operation record.

The advantage of RDB is that it is faster, and it stores binary files, so it is more convenient to transmit. The disadvantage is that RDB can't guarantee the absolute security of data, and sometimes even 1 s will cause great data loss.

The advantage of AOF is that it is safer than RDB, and there is generally no data loss. Even if there is a quantity, it won't be too big. Of course, the official suggestion is to open both AOF and RDB;; The disadvantage is that the persistence speed of AOF is slower than that of RDB, and the text file is stored, which will be larger in the later stage and difficult to transmit.

It should be noted that after restarting Redis, a persistent file needs to be loaded, and only the AOF file will be selected. If RDB is started first and then AOF is started, RDB will persist first, and the contents in RDB file will be overwritten by AOF.