This alert, redis_bgsave_slow
, indicates that the duration of the ongoing Redis RDB save operation is taking too long. This can be due to a large dataset size or a lack of CPU resources. As a result, Redis might stop serving clients for a few milliseconds, or even up to a second.
Redis RDB (Redis Database) is a point-in-time snapshot of the dataset. It's a binary file that represents the dataset at the time of saving. The RDB save operation is the process of writing the dataset to disk, which occurs in the background.
Use the top
command to see if the CPU usage is unusually high.
top
If the CPU usage is high, identify the processes that are consuming the most CPU resources and determine if they are necessary. Minimize the load by closing unnecessary processes.
Check the size of your Redis dataset using the INFO
command:
redis-cli INFO | grep "used_memory_human"
If the dataset size is large, consider optimizing your data structure or implementing data management strategies, such as data expiration or partitioning.
Use the following command to obtain the Redis statistics:
redis-cli INFO | grep "rdb_last_bgsave_time_sec"
Review the duration of the RDB save operation (rdb_last_bgsave_time_sec). If the save operation takes an unusually long time or fails frequently, consider optimizing your Redis configuration or improving your hardware resources like CPU and disk I/O.
To limit the frequency of RDB save operations, adjust the save
configuration directive in your Redis configuration file (redis.conf). For example, to save the dataset only after 300 seconds (5 minutes) and at least 10000 changes:
save 300 10000
After modifying the configuration, restart the Redis service for the changes to take effect.