Redis data backup offers two ways, one is a RDB, another is AOF.
RDB | AOF | |
switch on switch off | On: enabled by default; closed: the all save the configuration file is closed comments | ON: In the configuration file appendonly: yes that is opened aof; no off |
Synchronization mechanism | How many command synchronization can occur within a specified time, such as two times the command occurs within one minute, then do a synchronization | After each command sync or synchronization occurs per second |
Memory contents | Redis is stored in a specific value | Storage is to update the operation command execution |
Path to store files | To specify the path and file name based on the specific dir and dbfilenname | To specify a specific path and file name according to dir and appendfilename |
advantage | (1) storing data files are compressed, the file size is smaller than the AOF; (2) Since a specific value is stored in the Redis, and will be compressed, and therefore the recovery time faster than AOF; (3) is very suitable for backup. |
Backup mechanism (1) aof strategy is to occur or every time a write operation will be synchronized every minute, so even if a server fails, it will only lose one second of data; (2) it is stored aof Redis command and aof directly appended to the file, so long as each time the backup add new data into it; (3) If the aof file is large, then Redis will be rewritten, leaving only a minimum set of commands. |
Shortcoming | (1) rdb occurred in how much time the write operation is triggered when a synchronization mechanism, because the use of compression mechanism, rdb have to re-save the data in the entire Redis time synchronization, tends to set up five minutes before the first save data in this case, a general server failure will result in loss of data for at least 5 minutes; (2) in the data storage into the rdb time, Redis will fork a child process to synchronize, in the large amount of data, it may be very time consuming. |
(1) aof the file because there is no compression, thus larger than the volume of rdb; (2) aof is in second or each write operation is backed up, so if complicated by a greater amount, efficiency may be a bit slow; (3) aof file because storage is the command, and therefore will be re-run aof Redis commands at the time of disaster recovery, so recovery as fast as rdb. |