All Products
Search
Document Center

ApsaraDB for Redis:Use the real-time key statistics feature

Last Updated:Mar 12, 2024

ApsaraDB for Redis integrates the key analysis feature of Database Autonomy Service (DAS) to provide the real-time key statistics feature. This feature provides real-time and historical statistics about large keys and hotkeys, including the number of elements for large keys and the access frequency of hotkeys. When the memory usage or CPU utilization of an ApsaraDB for Redis instance increases, this feature can help you quickly find large keys and hotkeys to resolve performance issues in the instance.

Prerequisites

The instance is an ApsaraDB for Redis Community Edition instance that runs Redis 5.0 or later or an ApsaraDB for Redis Enhanced Edition (Tair) DRAM-based instance.

Statistical ranking mechanisms for large keys and hotkeys

Key type

Statistical ranking mechanism

Large keys

Keys that map to the List, Hash, Set, and Zset data structures are sorted and ranked based on the number of elements contained in the keys, with the top three keys being displayed. If two keys have the same number of elements, the key that first reaches this number ranks higher.

Note
  • For a cluster instance or a read/write splitting instance, the system displays the three largest keys in each data shard or each read replica. For more information about cluster instances and read/write splitting instances, see Cluster master-replica instances and Read/write splitting instances.

  • You can use the offline key analysis feature to obtain more statistics about large keys, such as the memory usage and distribution of keys, the memory usage and distribution of elements in keys, and the expiration time of keys. For more information, see Use the offline key analysis feature.

  • Keys that have not been accessed for a long time may not be included in the statistical ranking. For more information about how to obtain details about large keys, see Use the offline key analysis feature.

Hotkeys

ApsaraDB for Redis uses efficient sorting and statistical algorithms based on the Least Recently Used (LRU) key eviction policy to identify hotkeys in an instance.

Note
  • ApsaraDB for Redis Community Edition allows you to query up to 20 hotkeys at a time. ApsaraDB for Redis Enhanced Edition (Tair) allows you to query up to 50 hotkeys at a time.

  • In most cases, if the number of queries per second (QPS) is more than 3,000 for a key, the key is considered to be a hotkey.

Procedure

  1. Log on to the ApsaraDB for Redis 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.

  2. In the left-side navigation pane, choose CloudDBA > Real-time Key Statistics.

  3. Click the Real-time tab to view real-time data or click the History tab to view historical data based on your business requirements.

    Figure 1. Key analysisKey分析

    Note
    • If the instance is a cluster instance or a read/write splitting instance, you can select a node from the Current Node drop-down list.

    • If the queries per second (QPS) of a key reaches 6,000, the system stops calculating the accurate QPS of the key. In this case, >=6000 is displayed for such a hotkey in the Access Frequency column.

    • On the History tab, you can query the historical large keys and hotkeys within the last four days. The time range to query cannot exceed 3 hours. For example, if the current time is 16:00 on July 15, 2021, you can query the large keys and hotkeys from 16:00 on July 11 to 16:00 on July 15. If you set the beginning of the time range to query to 16:00 on July 11, the end of the time range to query cannot be later than 19:00 on July 11.

Related API operations

DAS API operation

Description

DescribeHotBigKeys

Queries the hotkeys and large keys in the memory in real time.

DescribeTopHotKeys

Queries the top 20 hotkeys over a period of time.

DescribeTopBigKeys

Queries the top 20 large keys over a period of time.

DescribeHotKeys

Queries the hotkeys of an ApsaraDB for Redis instance.