Redis Mixed RDB+AOF

According to the 4.0 change log:

Mixed RDB-AOF format – If enabled the new format is used when rewriting the AOF file: the rewrite uses the more compact and faster to generate RDB format, and an AOF stream is appended to the file. This allows faster rewrites and reloads when using the AOF persistence.

To configure the new mixed RDB+AOF format, you have to enable the following config in the redis config file:

aof-use-rdb-preamble yes

Using the mixed RDB+AOF uses more than twice disk space than RDB only as shown below, and this is for me an issue. As a DBA, i always care how our solutions utilize memory and disk whether we have a lot or not. And since redis is a memory-based database with capability to persist to disk, i would not want to focus so much on disk usage.

root@redis-notification-4:/~# ls -lh /opt/redis/redis_dump/          total 67M
-rw-rw---- 1 redis redis 45M Feb 11 14:06 appendonly.aof
-rw-rw---- 1 redis redis 22M Feb 11 14:20 dump.rdb

On redis-notification-1 shown below, i disabled aof-use-rdb-preamble and left on “appendonly yes” enabled and also “save 3400 90000”, and you can see that the size of AOF and RDB files are almost the same

root@redis-notification-1:/~# ls -lh /opt/redis/redis_dump/
total 44M
-rw-rw---- 1 redis redis 22M Feb 11 22:35 appendonly.aof
-rw-r----- 1 redis redis 22M Feb 11 22:35 dump.rdb
root@redis-notification-1:/~# ls -l 
total 44496
-rw-rw---- 1 redis redis 22777893 Feb 11 22:35 appendonly.aof
-rw-r----- 1 redis redis 22777979 Feb 11 22:35 dump.rdb

And if you try to view the appendonly.aof file when mixed ARD+AOF is used, it will show that it contains binary content for the RDB part:

root@redis-notification-4:/opt/redis/redis_dump# less appendonly.aof 
"appendonly.aof" may be a binary file.  See it anyway? 

The mixed RDB+AOF also uses the “appendonly.aof file. So for the mixed RDB+OAF (aof-use-rdb-preamble yes) to work, you also need to enable appendonly in the config file:

aof-use-rdb-preamble yes
aof-load-truncated yes
aof-rewrite-incremental-fsync yes
appendfilename "appendonly.aof"
appendfsync everysec
appendonly yes
Advertisements