August 29, 2013 10:56 am
In my today’s post i’d like to touch on Redis persistence mechanisms.
What we can choose from are basically two options (or the combination of those):
Both of those options are controlled by two different groups of configuration settings in the redis.conf file:
dumps the dataset on disk (RDB Persistence) which is a mode good enough in many applications, but an issue with the Redis process or
a power outage may result into a few minutes of writes lost (depending on
the configured save points). AOF provides much better durability. Using the default data
fsync policy Redis can lose just one second of writes in a dramatic event like a server power outage,
or a single write if something wrong with the Redis process itself happens, but the operating system
is still running correctly. AOF and RDB persistence can be enabled at the same and they play very nicely
together. If the AOF is enabled on startup Redis will load the AOF, that is the file with the better
durability guarantees.
appendfsync <mode> – mode in which fsync should operate. The fsync() call tells the Operating System to actually write data on disk
instead to wait for more data in the output buffer. Some OS will really flush
data on disk, some other OS will just try to do it ASAP. Redis supports three different modes:
background saving process (a background save or AOF log background rewriting) is
performing a lot of I/O against the disk, in some Linux configurations R
edis may block too long on the fsync() call. In order to mitigate this problem it’s possible to use this option
which will prevent fsync() from being called in the main process while a BGSAVE or BGREWRITEAOF is in progress.
In practical terms, this means that it is
possible to lose up to 30 seconds of log in the worst scenario (with the default
Linux settings).
Advantages and disadvantages of both methods (redis.io):
The general advice from Redis team is that you should use both persistence methods if you want a degree of data safety comparable to what PostgreSQL can provide you.
Take care!
Resources:
Posted by Mariusz Przydatek
Categories: Databases, NoSQL, Redis
Mobile Site | Full Site
Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.
[…] Redis Persistence – mariuszprzydatek.com | in search of … – stop-writes-on-bgsave-error – by default Redis will stop accepting writes if RDB snapshots are enabled (at least one save point) and the latest background save failed. This will make the user aware (in an hard way) … […]
By Fix Stop-writes-on-bgsave-error Yes Errors - Windows XP, Vista & Windows 7, 8 on October 26, 2014 at 12:49 am