In a Tair instance, the keys that are frequently accessed are called hotkeys. Improper management of hotkeys may cause congestion and degrade service performance. You can use the audit log feature to query and analyze historical hotkeys. This allows you to further optimize your instance.
Prerequisites
The audit log feature is enabled. For more information, see Enable the audit log feature.
The RAM user that you use to access audit logs has the permissions to access Simple Log Service.
You can attach the AliyunLogReadOnlyAccess or AliyunLogFullAccess system policy to a RAM user. After the policy is attached, the RAM user can view all Logstores. For more information, see Grant permissions to a RAM user.
You can also customize a policy to allow a RAM user to view only the audit logs of Tair.
Background information
Tair and Redis use efficient sorting and statistical algorithms based on the Least Frequently Used (LFU) key eviction policy to identify hotkeys in an instance. For Redis Community Edition 7.0.18, 6.0.2.9, or 5.5.2.9 instances or Tair DRAM-based instances of version 5.0.50 and later, the hotkey query feature uses a more direct and accurate statistical algorithm to provide more precise QPS.
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.
In this topic, audit logs are used to query historical hotkeys. For information about how to display hotkey information in real time, see Use the real-time key statistics feature.
Procedure
Log on to the Tair 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 left-side navigation pane, choose .
On the Audit Logs page, click the Official Version tab. In the upper-right corner, click Time Range. In the panel that appears, specify a time range that you want to query. In this example, 1 Week is selected, which specifies the previous week.
Clear the default filter conditions in the Keyword field, enter type:7, and then press the Enter key. The type:7 filter condition is used to query hotkeys.
In the Audit log detail section, view the details of the historical hotkeys.
NoteThe Client ip column displays 127.0.0.1, which is the IP address of the local host of the Tair instance.
In the Command column, view the details of the hotkeys. The following table describes the fields in the hotkey details.
Field
Example value
Description
dbid
"dbid":0
The database in which the hotkey resides.
type
"type":"string"
The type of data structure that the hotkey uses.
lfu
"lfu":241
The LFU value of the hotkey.
NoteFor Redis Community Edition 7.0.18, 6.0.2.9, or 5.5.2.9 instances or Tair DRAM-based instances of version 5.0.50 and later, this field is no longer used and is fixed to 0.
qps
"qps":"6000"
For Redis Community Edition 7.0.18, 6.0.2.9, or 5.5.2.9 instances or Tair DRAM-based instances of version 5.0.50 and later, this field indicates the exact QPS of the hotkey.
In earlier versions, the approximate QPS range can be displayed only if the QPS of a hotkey is less than 6,000. For example,
"qps":"4500-5000"
is a rough estimate of the QPS range, and 6000 is the maximum value in the approximate range.
key
"key":"key:000000000008"
The hotkey.