Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the important health indicators of Redis

2025-03-29 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly explains "what are the important health indicators of Redis". The content of the explanation is simple and clear, and it is easy to learn and understand. Please follow the editor's train of thought to study and learn what are the important health indicators of Redis.

Survival condition

Of course, the most important of all the metrics is to check whether redis is still alive, which can be determined by whether the response to the command PING is PONG.

Number of connections

The number of clients connected can be obtained by using the command src/redis-cli info Clients | grep connected_clients. This value is closely related to the connection pool configuration of the service using redis, so you need to pay attention to monitoring the value of this field. In addition, this value cannot be too large, and it is recommended that it not exceed 5000. If it is too large, it is possible that the redis processing is too slow, then you need to troubleshoot the problem to find out the cause.

There is also a number of rejected connections (rejected_connections) to pay attention to, which is ideally 0. If it is greater than 0, the number of connections created exceeds maxclients, and you need to troubleshoot the reason. Whether the configuration of redis connection pool is unreasonable or there are too many services connected to this redis instance, etc.

Number of blocking clients

Blocked_clients, which is usually caused by executing the BLPOP or BRPOP command of list data type, can be obtained by the command src/redis-cli info Clients | grep blocked_clients. Obviously, the value * * should be 0.

Use peak memory

To monitor the peak memory usage of redis, we all know that Redis can set the allowed * * memory by command config set maxmemory 10737418240 (it is strongly recommended not to exceed 20g). In order to prevent Redis performance from plummeting due to swap, or even to kill due to excessive memory usage, it is recommended that there is a safe range between the value of used_memory_peak and the value of maxmemory, for example, 1G, then the value of used_memory_peak cannot exceed 9663676416 (9G). In addition, we can also monitor how many gigabytes the maxmemory cannot be less than, such as 5G. Because of this problem in our production environment before, the operation and maintenance staff accidentally configured 10G to 1G, which led to the tragedy that the server had enough memory but could not be used.

Memory fragmentation rate

Mem_fragmentation_ratio=used_memory_rss/used_memory, this is also an indicator of great concern. If it is a previous version of redis4.0, there is no good way to optimize this problem other than a reboot. One of the main features of redis4.0 is the problem of optimizing memory fragmentation rate (Memory de-fragmentation). As described in the redis.conf configuration file, ACTIVE DEFRAGMENTATION: defragmentation allows Redis to compress memory space, thereby reclaiming memory. This feature is off by default and can be hot-started by command CONFIG SET activedefrag yes.

When this value is greater than 1, it means that the allocated memory exceeds the actual memory used, and the higher the value, the more serious the fragmentation rate.

When this value is less than 1, swap occurs, which means that there is not enough available memory.

It is also important to note that this value is of little reference value when the memory usage (used_memory) is very small. Therefore, it is recommended that at least 1G of used_memory should be considered to monitor the memory fragmentation rate.

Cache rate

Keyspace_misses/keyspace_hits is used to count the command rate of the cache. Keyspace_misses refers to the number of times not *, and keyspace_hits means * times. Keyspace_hits/ (keyspace_hits+keyspace_misses) is the cache * * rate. Depending on the situation, more than 0.9 is recommended, that is, the cache rate should exceed 90%. If the cache rate is too low, check to see if there is a problem with the use of the cache!

OPS

Instantaneous_ops_per_sec indicates cached OPS. If the business is relatively stable, this value will not fluctuate much. However, due to the comparative characteristics of domestic business, if it is not a globalized product, there is basically no traffic at night, so the monitoring of this field should be combined with your specific business, and the fluctuation range may vary from time to time.

Persistence

Rdb_last_bgsave_status/aof_last_bgrewrite_status, that is, whether there is a problem with the most recent or * * RDB/AOF persistence, both values should be "ok".

In addition, because redis persistence forks child processes, and fork is a completely blocked process, you can monitor fork time, that is, latest_fork_usec, in subtle units, if this value will affect the business, or even timeout.

Invalid KEY

If Redis is used as a cache, it is recommended that all key have the expire attribute set. Get the number of key in each db and the attribute of the key with the expire attribute set by the command src/redis-cli info Keyspace, and expires needs to be equal to keys:

# Keyspace db0:keys=30,expires=30,avg_ttl=0 db0:keys=23,expires=22,avg_ttl=0

Slow log

Get the slowlog collection executed by Redis through the command slowlog get. Ideally, the slowlog set should be empty, that is, there are no slow logs. However, sometimes it takes a few milliseconds for set key value command execution due to network fluctuations and other reasons, we need to pay attention to when monitoring, and can not see the slowlog thinking about optimization, simple set/get may also appear in slowlog.

Thank you for your reading, the above is the content of "what are the important health indicators of Redis". After the study of this article, I believe you have a deeper understanding of what the important health indicators of Redis are, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report