AOF and RDB backups in redis

Does this mean that practically, I’m getting backups every 60 seconds?

NO. Redis does a background save after 60 seconds, if there’re at least 10000 keys have been changed. Otherwise, it doesn’t do a background save.

Will using appendonly on and appendfsync everysec cause a performance downgrade? Will it hit the CPU? The write load is on the high side.

It depends on many things, e.g. disk performance (SSD VS HDD), write/read load (QPS), data model, and so on. You need do a benchmark with your own data in your specific environment.

Once I restart the redis server with these new settings, I’ll still lose the last 60 secs of my data, correct?

NO. If you turn on both AOF and RDB, when Redis restarts, the AOF file will be used to rebuild the database. Since you config it to appendfsync everysec, you will only lose the last 1 second of data.

Are restart times something to worry about? My dump.rdb file is small; ~90MB.

If you turn on AOF, and when Redis restarts, it replays logs in AOF file to rebuild the database. Normally AOF file is larger then RDB file, and it might be slower than recovering from RDB file. Should you worry about that? Do a benchmark with your own data in your specific environment.

EDIT

IMPORTANT NOTICE

Assume that you already set Redis to use RDB saving, and write lots of data to Redis. After a while, you want to turn on AOF saving. NEVER MODIFY THE CONFIG FILE TO TURN ON AOF AND RESTART REDIS, OTHERWISE YOU’LL LOSE EVERYTHING.

Because, once you set appendonly yes in redis.conf, and restart Redis, it will load data from AOF file, no matter whether the file exists or not. If the file doesn’t exist, it creates an empty file, and tries to load data from that empty file. So you’ll lose everything.

In fact, you don’t have to restart Redis to turn on AOF. Instead, you can use config set command to dynamically turn it on: config set appendonly yes.

Leave a Comment