If the memory usage or CPU utilization of your Tair or Redis instance is high, you can use the Top Key Statistics feature to quickly find large keys and hot keys. This feature displays real-time and historical information about large keys and hot keys in an instance, such as keys with many elements, keys that use a large amount of memory, and frequently accessed hot keys. This information helps you resolve instance performance issues.
Statistical and ranking mechanism for large keys and hot keys
To avoid consuming extra database resources, this feature collects statistics only on keys that clients have accessed through read or write operations. It retains and displays only the top keys for each key type and does not scan all keys in the database in real time. After an instance is restarted or a high availability (HA) switchover occurs, the collected top key information is cleared and the statistical process restarts. Therefore, keys that have not been accessed for a long time may not be included in the statistics. To obtain information about the memory usage and distribution of all keys in the database, you can use the Offline Key Analysis feature.
Key type | Applicable versions | Statistical mechanism | Display description |
Large key (by number of elements) |
| A key is counted as a large key when its number of elements, such as the number of fields in a Hash or members in a Set, reaches or exceeds the threshold. The default threshold is 2000. You can customize the threshold by setting the Note If this parameter is not displayed in the parameter settings, you can perform a minor version update and try again. | A maximum of the top three large keys for each data type are displayed. If keys have the same number of elements, the key that was written first is prioritized. Note If the instance displays a total of only 3 large keys, you can update the minor version and retry. |
Large key (by memory usage) | Cloud-native memory-optimized instances of Tair (Enterprise Edition) with minor version 25.6.0.0 or later. |
| A maximum of the top three keys are displayed. If keys are the same size, they are sorted in lexicographic order. |
Hot key (by QPS) |
| A key is recorded as a hot key when its queries per second (QPS) exceeds 5000. You can customize the threshold by setting the | At any given time, the system displays a maximum of the top 50 hot keys and shows their precise real-time QPS. |
Hot key (by traffic) | Cloud-native memory-optimized instances of Tair (Enterprise Edition) with minor version 25.2.0.0 or later. | A key is recorded as a hot key if its access traffic exceeds 1 MB/s.
| At any given time, the system displays a maximum of the top 50 hot keys and shows their precise inbound and outbound traffic and access frequency. Note Statistics can be collected for keys that do not exist. If the data type is displayed as not-exist-key, it means the key does not exist but is frequently accessed. |
Procedure
Log on to the console and go to the Instances page. In the top navigation bar, select the region in which the instance that you want to manage resides. Then, find the instance and click the instance ID.
In the navigation pane on the left, click .
Choose to query real-time or historical data.
Figure 1. Key analysis
NoteIf the instance uses a cluster architecture or a read/write splitting architecture, select a node from the Current Node drop-down list to display its data.
When you query historical data, you can query information about large keys and hot keys from the last four days. The maximum time range for a single query cannot exceed three hours.
Related API operations
DAS API operations | Description |
Gets real-time information about hot keys and large keys that are currently in memory. | |
Gets information about the top 20 hot keys over a period of time. | |
Gets information about the top 20 large keys over a period of time. | |
Gets information about the hot keys of a Redis instance. |
FAQ
Q: Why are String-type keys displayed under Large key (by number of elements)?
A: In Redis Open-Source Edition and some earlier versions of Tair, keys of the String type are displayed if their length exceeds the threshold. The default threshold is 2000.
Q: Why is a key with very few elements, such as fewer than 10, displayed as a large key?
A: There are two possible reasons.
The key name itself is large. You can run the
memory usage key_namecommand to check its size.The minor version of the instance is too old. For instances with a minor version earlier than 5.2.7, the default value of
bigkey-threshold(the threshold for large key statistics) is 0. This causes keys with small memory usage to be displayed. You can upgrade the minor version to the latest version.