In an ApsaraDB for Redis database, the keys that are frequently accessed are called hot keys. The improper management of hot keys may cause Redis processes to be blocked and result in service interruption. You can use the Audit Log feature to query the history of hot keys and analyze the history. This allows you to further optimize the database.

Background information

Based on the Least Frequently Used (LFU) algorithm, ApsaraDB for Redis uses efficient sorting and statistical algorithms to identify the hot keys on an instance.
Note If the number of queries per second (QPS) of a key is greater than 3,000, the key is regarded as a hot key.

Procedure

  1. Log on to the ApsaraDB for Redis console.
  2. On the top of the page, select the region where the instance is deployed.
  3. On the Instances page, click the Instance ID of the instance.
  4. The Instance Information page appears. In the left-side navigation pane, choose Logs > Audit Log.
  5. On the Audit Log page, click Please Select in the upper-right corner of the page. In the Time pane, specify a time range that you want to query. In this example, 1 Week is selected to query the history that was generated in the last week.
    Select a time range
  6. Clear the Keyword field, enter type:7 in the field, and then press Enter.
    Set the Keyword field
  7. The Audit log detail section displays the history of hot keys that are returned.
    History of hot keys
    Note The Client ip column displays 127.0.0.1 to indicate the IP address of the local host of the ApsaraDB for Redis instance.

    The Command column displays the details of the hot keys that are found. The following table describes the fields in each command.

    Field Example Description
    dbid "dbid":0 The database in which the hot key is located.
    type "type":"string" The type of data structure that the hot key uses.
    lfu "lfu":241 The LFU value of the hot key.
    qps "qps":"4500-5000" The QPS of the hot key. The value is displayed as a range.
    key "key":"key:000000000008"} The hot key that is returned.