Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does Redis RDB run bgsave or save?

Tags:

redis

I am using Redis as more of a temporary store, but there are some fields that I want to persist, so I want to use RDB. A few minutes lost will not hurt. However I am noticing that at times I get big IO Wait spikes on my server and I believe it is when an RDB save is occurring.

I found that there are two commands when running manually, BGSAVE and SAVE. They do the same thing, but BGSAVE allows for background saving to ensure that redis does not block any new writes/reads.

The config file for saving has lines similar to:

save 10 1000

save 100 500

Is this literally meaning that it is using the SAVE command and if so, can I replace that with bgsave and get my expected/needed results?

like image 337
nightsurgex2 Avatar asked Jul 15 '15 14:07

nightsurgex2


People also ask

How does Redis RDB work?

Redis is very data backup friendly since you can copy RDB files while the database is running: the RDB is never modified once produced, and while it gets produced it uses a temporary name and is renamed into its final destination atomically using rename(2) only when the new snapshot is complete.

What is Bgsave in Redis?

Redis BGSAVE command saves the DB in the background. The OK code is immediately returned. Redis forks, the parent continues to serve the clients, the child saves the DB on the disk, then exits. A client may be able to check if the operation succeeded using the LASTSAVE command.

What is RDB file in Redis?

RDB is for Redis Database Backup file. RDB file is a dump of all user data stored in an internal, compressed serialization format at a particular timestamp which is used for point-in-time recovery (recovery from a timestamp).

How does Redis save?

Within Redis, there are two different ways of persisting data to disk. One is a method called snapshotting that takes the data as it exists at one moment in time and writes it to disk. The other method is called AOF, or append—only file, and it works by copying incoming write commands to disk as they happen.


1 Answers

The configuration's save directive invokes the same mechanism as BGSAVE, i.e. it will not block the server. I totally understand, however, why this is confusing.

like image 185
Itamar Haber Avatar answered Oct 04 '22 09:10

Itamar Haber