Live Blog

Redis Memory Usage When Restarting

You might receive false positives from your monitor software (monit, netdata) about about redis taking up double the amount of memory it has been configured with.

[EST Jan  9 14:25:01] warning  : 'redis-server' total mem amount of 3.3 GB matches resource limit [total mem amount > 1.7 GB]

Looking further reveals that two redis-server processes are spawned at some point. Digging further it looks like when Redis is saving to rdb it’s spawning a second process which stays alive enough for monit to complain.

311844:M 09 Jan 2023 14:25:00.019 * 10 changes in 300 seconds. Saving...
311844:M 09 Jan 2023 14:25:00.052 * Background saving started by pid 739360
739360:C 09 Jan 2023 14:25:06.876 * DB saved on disk
739360:C 09 Jan 2023 14:25:06.903 * RDB: 7 MB of memory used by copy-on-write
311844:M 09 Jan 2023 14:25:06.968 * Background saving terminated with success

You can read more about the RDB saving as what happens Redis persistence | Redis

If redis is restarted at a specific time that aligns with monit’s check time it’s possible that an alert can be sent out. There is the option of using AOF, which wouldn’t require a restart. You would just need to update this setting in the redis.conf file

appendonly on