Databases Reference
In-Depth Information
Persistence
Redis supports two persistence mechanisms that can be used to store the data set on
disk. They are as follows:
RDB is the simplest persistence mechanism of Redis. It takes snapshots from
the in-memory data sets at configured intervals, and stores the snapshot on
disk. When a server is started, it will read the data set back to the memory
from the snapshot file. This is the default persistence mechanism of Redis.
RDB maximizes the performance of your Redis server, and its file format is
really compact, which makes it a very useful tool for disaster recovery. Also,
if you want to use the master-slave replication, you have to use RDB because
the RDB snapshots are used when the data is synchronized between the
master and the slaves.
However, if you have to minimize the chance of data loss in all situations,
RDB is not the right solution for you. Because RDB persists the data at
configured intervals, you can always lose the data stored in to your Redis
instance after the last snapshot was saved to a disk.
Append Only File ( AOF ) is a persistence model, which logs each operation
changing the state of the in-memory data set to a specific log file. When
a Redis instance is started, it will reconstruct the data set by executing all
operations found from the log file.
The advantage of the AOF is that it minimizes that chance of data loss in all
situations. Also, since the log file is an append log, it cannot be irreversibly
corrupted. On the other hand, AOF log files are usually larger than RDB
files for the same data, and AOF can be slower than RDB if the server is
experiencing a huge write load.
You can also enable both persistence mechanisms and get the best of both worlds.
You can use RDB for creating backups of your data set and still ensure that your
data is safe. In this case, Redis will use the AOF log file for building the data set on a
server startup because it is most likely that it contains the latest data.
If you are using Redis as a temporary data storage and do not need persistency,
you can disable both persistence mechanisms. This means that the data sets will be
destroyed when the server is shut down.
 
Search WWH ::




Custom Search