Being new to Redis myself, I need to start reading up more on it especially with regards to the Redis database being in memory and what that means for database persistence and reliability in event of failure.
So this thread just serves as a collection point for useful Redis info and links that I find during my reading that might help others.
Redis Quickstart
Redis database persistence and reliability
- Redis Persistence - RDB and AOF persistence
- Redis persistence demystified
Redis persistence
You can learn how Redis persisence works in this page, however what is important to understand for a quick start is that by default, if you start Redis with the default configuration, Redis will spontaneously save the dataset only from time to time (for instance after at least five minutes if you have at least 100 changes in your data), so if you want your database to persist and be reloaded after a restart make sure to call the SAVE command manually every time you want to force a data set snapshot. Otherwise make sure to shutdown the database using the SHUTDOWN command:
$ redis-cli shutdown
This way Redis will make sure to save the data on disk before quitting. Reading the persistence page is strongly suggested in order to better understand how Redis persistence works.
Looks like for Redis 2.8.6 redis.conf AOF is disabeld by default and the default RDB snapshot settings in redis.conf are as follows
checking my local test NodeBB with Redis 2.8.6
ls -lah /var/lib/redis;date
total 20K
drwxr-xr-x 2 redis root 4.0K Feb 27 08:30 .
drwxr-xr-x. 23 root root 4.0K Feb 25 19:34 ..
-rw-r--r-- 1 redis redis 8.5K Feb 27 08:30 dump.rdb
Thu Feb 27 08:30:54 EST 2014
from redis.conf it looks like if you have a low activity NodeBB forum using Redis database, the snapshots are written to disk every 5-15mins. If you have a very active forum with >10,000 key changes then it will write to disk the snapshot every 60 seconds or 1 min. In a way still better than MySQL out of the box as unless you specifically setup a MySQL backup policy/plan, you don't get any backups at all !
################################ SNAPSHOTTING ################################
#
# Save the DB on disk:
#
# save <seconds> <changes>
#
# Will save the DB if both the given number of seconds and the given
# number of write operations against the DB occurred.
#
# In the example below the behaviour will be to save:
# after 900 sec (15 min) if at least 1 key changed
# after 300 sec (5 min) if at least 10 keys changed
# after 60 sec if at least 10000 keys changed
#
# Note: you can disable saving at all commenting all the "save" lines.
#
# It is also possible to remove all the previously configured save
# points by adding a save directive with a single empty string argument
# like in the following example:
#
# save ""
save 900 1
save 300 10
save 60 10000
# 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 a hard way) that data is not persisting
# on disk properly, otherwise chances are that no one will notice and some
# disaster will happen.
#
# If the background saving process will start working again Redis will
# automatically allow writes again.
#
# However if you have setup your proper monitoring of the Redis server
# and persistence, you may want to disable this feature so that Redis will
# continue to work as usual even if there are problems with disk,
# permissions, and so forth.
stop-writes-on-bgsave-error yes
# Compress string objects using LZF when dump .rdb databases?
# For default that's set to 'yes' as it's almost always a win.
# If you want to save some CPU in the saving child set it to 'no' but
# the dataset will likely be bigger if you have compressible values or keys.
rdbcompression yes
# Since version 5 of RDB a CRC64 checksum is placed at the end of the file.
# This makes the format more resistant to corruption but there is a performance
# hit to pay (around 10%) when saving and loading RDB files, so you can disable it
# for maximum performances.
#
# RDB files created with checksum disabled have a checksum of zero that will
# tell the loading code to skip the check.
rdbchecksum yes
# The filename where to dump the DB
dbfilename dump.rdb
# The working directory.
#
# The DB will be written inside this directory, with the filename specified
# above using the 'dbfilename' configuration directive.
#
# The Append Only File will also be created inside this directory.
#
# Note that you must specify a directory here, not a file name.
dir /var/lib/redis/