How to do it...

You should make sure you are able to get alerted when the memory issues happen:

  1. Firstly, watch out if the used_memory_human metric is greater than the metric maxmemory_human:
$ bin/redis-cli INFO MEMORY|egrep "used_memory_human|maxmemory_human"
used_memory_human:1016.45M
maxmemory_human:1.00G  
  1. Test regularly to see if it's working properly by writing a simple key value pair into the Redis instance:
127.0.0.1:6379> SET foo bar
(error) OOM command not allowed when used memory > 'maxmemory'.  
  1. Take a note of when the metric evicted_keys has increased:
$ bin/redis-cli INFO Stats|grep evicted_keys
evicted_keys:382901 
  1. Next, check the system memory and swap space utilization of the redis-server process:
$ bin/redis-cli INFO ...

Get Redis 4.x Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.