Use the Database Autonomy Service (DAS) key analysis feature to identify large keys (big keys) and hot keys in your Redis instance in real time. By monitoring key access frequency and element counts, this feature provides the data you need to optimize your database. This can help you prevent issues like insufficient memory and performance degradation caused by skewed key distribution.
Prerequisites
Your instance must be a compatible Redis or Tair instance:
Redis: open-source compatible, version 5.0 or later.
Tair (Redis Enterprise Edition): memory-optimized or persistent memory instance.
Statistical ranking mechanisms for large keys and hotkeys
To avoid additional resource consumption on the database, this feature only collects statistics of keys that have been read or written by the client. It retains and displays the top keys for each type but does not perform a real-time scan of all the keys in the database. Additionally, after an instance restart or high availability (HA) failover, the previously recorded top key information will be cleared, and the statistics will begin anew. Therefore, keys that have not been accessed for a long time may not be included in the statistics. To obtain information about all keys in the database, including the memory usage and distribution by quantity, use the offline key analysis feature.
Key type | Statistical ranking mechanism |
Large keys (keys with a large number of elements) | Keys are ranked based on the string length (only for the String type) or number of elements. When the string length or number of elements in a key reaches 2,000 or more, the key is counted as a large key. Note The system displays up to three top-ranked keys for each data type. When multiple keys have the same number of elements, the key that is written first is displayed first. If only three large keys are displayed for your instance, update the minor version and try again. |
Large keys (keys that consume a significant amount of memory) | Keys are ranked based on memory usage. The MEMORY USAGE command is used to determine the memory usage of each key. When a single element is larger than 50 KB or the entire object is larger than 500 MB, the key is counted as a large key. Note
|
Hotkeys | When the number of queries per second (QPS) of a key exceeds 5,000, the key is recorded as a hotkey, and its exact QPS is displayed in real time. The system can track up to 50 hotkeys at the same time. Note We recommend that you upgrade your Redis Open-Source Edition instance to 7.0.18, 6.0.2.9, or 5.5.2.9, or upgrade your Tair DRAM-based instance to 5.0.50, 24.5.1.0, or later. In earlier versions, a key is recorded as a hotkey when its QPS exceeds 3,000, and only an approximate QPS range is displayed. Additionally, up to 20 hotkeys can be tracked at the same time for each Redis Open-Source Edition instance. |
Procedure
Log on to the DAS console.
In the left-side navigation pane, choose Intelligent O&M Center > Instance Monitoring.
Click the Redis tab.
On the page that appears, find the database instance that you want to manage and click the instance ID. The instance details page appears.
In the navigation pane on the left, click Top Key Statistics.
Click the Real-time or History tab to view the information about hot keys and large keys.
NoteOn the History tab, you can query information about large keys and hot keys analyzed within the last four days. The maximum interval between the start time and the end time is 3 hours.
References
For more information about how to use this feature in the Tair console, see Top key statistics.
Related API operations
API | Description |
Queries the hotkeys and large keys in the memory in real time. | |
Queries the top 100 hotkeys over a period of time. | |
Queries the top 100 large keys over a period of time. | |
Queries the hotkeys of an instance. |