Persistence
RDB (Redis Database): This method takes snapshots of your database at specified intervals. It's efficient for saving a compact, point-in-time snapshot of your dataset. The RDB file is a binary file that Redis can use to restore its state.
Synchronous save of the dataset to disk. When Redis starts the save operation, it blocks all the clients until the save operation is complete. NOT RECOMMENDED IN PROD.
Background SAVE or Asynchronous SAVE. This forks a new process, and the child process writes the snapshot to the disk. It is used in Prod as Redis continues to process commands while the snapshot is being created.
Automation
Saves the datasets every 900 seconds if at least one write operation has occurred.
Saves the datasets every 300 seconds if at least 10 write operations have occurred.
You can have multiple SAVE in redis.conf file for different conditions.
It creates a dump.rdb file (it is configurable to different name in redis.conf)
How to load from RDB?
When Redis is restarted, it checks for the RDB file and loads the contents to memory.
AOF (Append Only File): This method logs every write operation the server receives, appending each operation to a file. This allows for more granular persistence and more durability than RDB, as you can configure Redis to append data on every write operation at the cost of performance. The AOF file can be replayed to reconstruct the state of the data.
Last updated