Monitoring Redis Performance Metrics

Monitoring Metrics
  • Performance metrics: Performance
  • Memory metrics: Memory
  • Basic activity metrics: Basic activity
  • Persistence metrics: Persistence
  • Error metrics: Error
    Performance Metrics: Performance
Name Description
latency The time Redis takes to respond to a request
instantaneous_ops_per_sec Average total number of requests processed per second
hi rate(calculated) Cache hit rate (calculated
Memory Metrics: Memory
Name Description
used_memory Memory in use
mem_fragmentation_ratio Memory fragmentation ratio
evicted_keys Number of keys removed due to the max memory limit
blocked_clients Clients blocked by BLPOP, BRPOP, or BRPOPLPUSH
Basic Activity Metrics: Basic activity
Name Description
connected_clients Number of client connections
conected_laves Number of slaves
master_last_io_seconds_ago Seconds since the last master-slave interaction
keyspace Total number of keys in the database
Persistence Metrics: Persistence
Name Description
rdb_last_save_time Timestamp of the last persistence save to disk
rdb_changes_sice_last_save Number of database changes since the last persistence save
Error Metrics: Error
Name Description
rejected_connections Number of connections rejected due to the maxclient limit
keyspace_misses Number of failed key lookups (cache misses)
master_link_down_since_seconds Duration of the master-slave disconnection (in seconds)
Monitoring Approaches
  • redis-benchmark
  • redis-stat
  • redis-faina
  • redislive
  • redis-cli
  • monitor
  • showlog

1.get: get the slow query log

2.len: get the number of slow query log entries

3.reset: reset the slow query log

Related configuration:

slowlog-log-slower-than 1000 # Set the slow query time threshold, unit: microseconds
slowlog-max-len 100 # Set the log display length for slow query commands, unit: number of commands

info (you can get all the information at once, or get it block by block)

1.server: environment parameters of the server runtime

2.clients: client-related information

3.memory: memory statistics of the server runtime

4.persistence: persistence information

5.stats: general statistics

6.Replication: master-slave replication-related information

7.CPU: CPU usage

8.cluster: cluster information

9.Keypass: key-value pair count statistics

Using the info Command in a Terminal
./redis-cli info get info by block | grep parameters to filter

./redis-cli info stats | grep ops
Using the Interactive info Command
 #./redis-cli 
> info server
Performance Monitoring:
redis-cli info | grep ops # operations per second
Memory Monitoring
[root@CombCloud-2020110836 src]# ./redis-cli info | grep used | grep human       
used_memory_human:2.99M  # Total memory allocated by the memory allocator from the operating system
used_memory_rss_human:8.04M  # Memory usage as seen by the operating system, i.e. what the top command shows
used_memory_peak_human:7.77M # Peak Redis memory consumption
used_memory_lua_human:37.00K   # Amount of memory used by the Lua script engine
Clients Blocked by BLPOP, BRPOP, or BRPOPLPUSH
[root@CombCloud-2020110836 src]# ./redis-cli info | grep blocked_clients
blocked_clients:0  
Number of Keys Removed Due to the Max Memory Limit
[root@CombCloud-2020110836 src]# ./redis-cli info | grep evicted_keys
evicted_keys:0  #
Memory Fragmentation Ratio
[root@CombCloud-2020110836 src]# ./redis-cli info | grep mem_fragmentation_ratio
mem_fragmentation_ratio:2.74 
Memory in Use
[root@CombCloud-2020110836 src]# ./redis-cli info | grep used_memory:
used_memory:3133624  
Basic Activity Metrics:

How many clients Redis has connected. By watching the count you can confirm whether there are any unexpected connections. If the number looks off, you can use the lcient list instruction to list all client connection addresses and pin down the source.

[root@CombCloud-2020110836 src]# ./redis-cli info | grep connected_clients
connected_clients:1


[root@CombCloud-2020110836 src]# ./redis-cli info | grep connected
connected_clients:1   # Number of client connections
connected_slaves:1   # Number of slave connections
Persistence Metrics:
[root@CombCloud-2020110836 src]# ./redis-cli info | grep rdb_last_save_time
rdb_last_save_time:1591876204  # Timestamp of the last persistence save to disk
[root@CombCloud-2020110836 src]# ./redis-cli info | grep rdb_changes_since_last_save
rdb_changes_since_last_save:0   # Number of database changes since the last persistence save
Error Metrics

The number of client connections rejected because the maximum connection limit was exceeded. If this number is very large, it means the server’s maximum connection count is set too low and maxclients needs to be adjusted.

[root@CombCloud-2020110836 src]# ./redis-cli info | grep connected_clients
connected_clients:1

The number of failed key lookups (cache misses). If it occurs many times, it may mean a hacker attack.

[root@CombCloud-2020110836 src]# ./redis-cli info | grep keyspace
keyspace_misses:0   

The duration of the master-slave disconnection (in seconds).

[root@CombCloud-2020110836 src]# ./redis-cli info | grep rdb_changes_since_last_save
rdb_changes_since_last_save:0  

If the replication backlog buffer is set too small, the instructions inside it will be overwritten and the offset can no longer be found, which triggers a full resynchronization.

[root@CombCloud-2020110836 src]# ./redis-cli info | grep backlog_size
repl_backlog_size:1048576

Check the number of times the sync_partial_err variable has been set to decide whether the backlog buffer needs to be enlarged. It represents the number of failed master-slave partial resynchronizations.

[root@CombCloud-2020110836 src]# ./redis-cli info | grep sync_partial_err
sync_partial_err:1

redis performance testing command

./redis-benchmark -c 100 -n 5000

Original source: https://mp.weixin.qq.com/s/gu1ZLXlR9ud4wnssYMVkMw