Command to view redis memory information

Time:2020-9-23

View redis memory usage

The info command is used to monitor the operation of redis. Info memory can view the statistics of redis memory usage


redis-cli info memory

The output result of the command is as follows:

The information in the first few fields is the most important

Property name Attribute description
used_memory The total amount of memory allocated by redis allocator, that is, the amount of internal storage of all data
used_memory_human Returns used in a readable format_ memory
used_memory_rss From the perspective of operating system, it shows the total amount of physical memory occupied by redis process
used_memory_rss_human used_ memory_ Display of RSS user readable format
used_memory_peak The maximum amount of memory used, indicating used_ The peak of memory
used_memory_peak_human Returns used in a readable format_ memory_ Value of peak

View key statistics

KeysThe command performance is very poor. It is a business killer to use the command online. Therefore, it is recommended that the production environment block the keys command. If you just want to view the key statistics, you can use two other commands:

1. dbsize: view the number of valid keys in the current database

2. info keyspaceinfoThe command gives the key information of each database of redis instance

The output of the two commands is as follows:

As you can see,info keyspaceThe command gives more complete statistics.

View the key that takes up the most memory

To check which key occupies the largest memory in the database, you can use the — bigkeys parameter:


redis-cli -n 5 --bigkeys

The command output is as follows:

The running results show the 10 keys with the highest memory consumption in the order from small to large. In the above result, the maximum key value takes up more than 300 K of memory.

For string type, the output of bigkeys is correct. However, there may be problems with the calculation method of bigkeys for data structures such as list and sets. Please pay attention to the points in practice.

in addition--bigkeysThe parameters also give the statistics of keys information. In the above output, all the data is of string type, and there is no list, sets and other types of data.

The above is the details of the command to view redis memory information. For more information about viewing redis memory information, please pay attention to other related articles in developeppaer!

Recommended Today

Introduction to pyzmq

Introduction to pyzmq ZMQ (hereinafter referred to as ZMQ) is a simple and easy-to-use transport layer, like a socket library framework, it makes socket programming more simple, concise and higher performance. Is a message processing queue library that can be flexibly scaled between multiple threads, kernel and mainframe. ZMQ’s clear goal is to “become part […]