All Products
Search
Document Center

Database Autonomy Service:Key analysis

Last Updated:Sep 14, 2024

Database Autonomy Service (DAS) provides the key analysis feature. This feature allows you to view the large keys and hot keys in your database instance in real time. You can also view the large keys and hot keys that are detected in the last four days. This allows you to obtain data such as the key access frequency and the number of elements. You can optimize database performance based on the obtained data. This feature also helps you prevent issues caused by unbalanced distribution of keys in the memory, such as insufficient memory and reduced performance.

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 or persistent memory-optimized instance.

Statistical ranking mechanisms for large keys and hotkeys

Key type

Statistical ranking mechanism

Large keys

  • Supported data types

    • Native Redis data structures: String, List, Hash, Set, Zset, and Stream.

    • Self-developed Tair data structures: TairString, TairHash, TairGIS, TairBloom, TairDoc, TairCpc, TairZset, TairRoaring, TairTS, and TairSearch.

  • Large keys (keys with a large number of elements)

    • Statistical threshold: 2,000 (string length or number of elements).

    • Number of large keys per master node: 3. If the instance uses the cluster or read/write splitting architecture, the system displays the three largest keys of each data type in each data shard or read replica.

    • Statistical rules:

      • Keys are ranked based on the string length (for the String type) or number of elements (for other data types).

      • If keys differ in size, the system selects the top three keys that meet or exceed the defined threshold.

      • If multiple keys have the same size, the key that is scanned first during the statistical scan is ranked higher.

  • Large keys (keys that occupy a large amount of memory)

    Note

    Only ApsaraDB for Redis Enhanced Edition (Tair) DRAM-based instances of version 6.0 or later are supported.

    • Statistical threshold: A single element is larger than 50 KB or an entire key is larger than 500 MB.

    • Number of large keys per master node: 3. If the instance uses the cluster or read/write splitting architecture, the system displays the three largest keys of each data type in each data shard or read replica.

    • Statistical rules:

      • Keys are ranked based on the amount of memory that they consume. The MEMORY USAGE command is used to determine the memory usage of each key.

      • If keys differ in memory usage, the system selects the top three keys that meet or exceed the defined threshold.

      • If multiple keys have the same memory usage, they are sorted in lexicographical order.

Note

Keys that have not been accessed for a long period of time may not be included in the statistical ranking. You can use the offline key analysis feature to obtain information about large keys, such as the memory usage of keys, the distribution of keys, the memory usage and distribution of elements in keys, and the distribution of time-to-live (TTL) values across keys. For more information, see Cache analysis.

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

For Redis Community Edition instances of version 7.0.18, 6.0.2.9, or 5.5.2.9 or Tair DRAM-based instances of version 5.0.50 and later, the following enhancements to hotkeys are made:

  • Statistics about up to 50 hotkeys can be collected at the same time. In the previous versions of Redis Community Edition, only statistics about up to 20 hotkeys can be collected at the same time.

  • A key is considered a hotkey if its queries per second (QPS) exceeds 5,000. In earlier versions, a key is considered a hotkey if its QPS exceeds 3,000.

  • The exact QPS of a hotkey can be displayed. In earlier versions, the approximate QPS range can be displayed only if the QPS of a hotkey is less than 6,000.

Procedure

  1. Log on to the DAS console.

  2. In the left-side navigation pane, click Instance Monitoring.
  3. Find the database instance that you want to manage and click the instance ID. The instance details page appears.
  4. In the left-side navigation pane, click Key Analysis.

  5. Click the Real-time or History tab to view the information displayed in the Hot Key and Big Key sections.

    Note

    On the History tab, you can query the information of large keys and hot keys that are 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 the key analysis feature in the ApsaraDB for Redis console, see Use the real-time key statistics feature.

Related operations

Operation

Description

DescribeHotBigKeys

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

DescribeTopHotKeys

Queries the top 100 hot keys over a period of time.

DescribeTopBigKeys

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

DescribeHotKeys

Queries the hot keys of an ApsaraDB for Redis instance.