Understanding Redis RDB Persistence: Configuration, Snapshot Triggers, and Pros & Cons
This article explains how Redis RDB persistence works, detailing the save configuration parameters, snapshot generation methods, differences between SAVE and BGSAVE, storage locations, and the advantages and disadvantages of using RDB snapshots.
Redis can be configured to automatically create an RDB snapshot when a certain number of keys are modified within a given time interval. The three default save directives are:
save 900 1 # after 900 seconds if at least 1 key changed
save 300 10 # after 300 seconds if at least 10 keys changed
save 60 10000 # after 60 seconds if at least 10000 keys changed
When all three options are disabled, RDB persistence is turned off.
A Redis snapshot (RDB file) is a point‑in‑time copy of the entire in‑memory dataset written to disk, allowing fast recovery by loading the binary file (default name dump.rdb ). Unlike AOF, which replays command logs, RDB stores the data directly.
Snapshots can be generated in several ways:
Manually via the bgsave command.
Manually via the save command.
Automatically according to the save configuration in the redis.conf file.
When a client issues shutdown , Redis first runs save , blocks the client, then stops.
In a master‑slave setup, the master runs bgsave when a slave sends a sync command.
The difference between save and bgsave is that save blocks the Redis process while bgsave forks a child process and runs in the background without blocking.
RDB files are stored in the Redis process’s working directory, with the path and filename controlled by the dir and dbfilename configuration options.
Advantages of RDB persistence include:
Compact binary format makes backups simple.
Forked child process maximizes performance.
Fast startup time.
Disadvantages include:
Potential data loss if the server crashes between snapshot intervals (commonly 15 minutes or 30 minutes).
Overhead of the forked child process.
If you found this article helpful, please like, share, and follow to support further content creation.
Practical DevOps Architecture
Hands‑on DevOps operations using Docker, K8s, Jenkins, and Ansible—empowering ops professionals to grow together through sharing, discussion, knowledge consolidation, and continuous improvement.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.