Help Center> Distributed Cache Service> FAQs> Big/Hot Key Analysis and Expired Key Scan> How Do I Detect Big Keys and Hot Keys in Advance?
Updated on 2023-09-08 GMT+08:00

How Do I Detect Big Keys and Hot Keys in Advance?

Method

Description

Through Big Key Analysis and Hot Key Analysis on the DCS console

See Analyzing Big Keys and Hot Keys.

By using the bigkeys and hotkeys options on redis-cli

  • redis-cli uses the bigkeys option to traverse all keys in a Redis instance and returns the overall key statistics and the biggest key of six data types: Strings, Lists, Hashes, Sets, Zsets, and Streams. The command is redis-cli -h <Instance connection address> -p <Port number> -a <Password> --bigkeys.
  • In Redis 4.0 and later, you can use the hotkeys option to quickly find hot keys in redis-cli. Run this command during service running to find hot keys: redis-cli -h <Instance connection address> -p <Port number> -a <Password> --hotkeys. The hot key details can be obtained from the summary part in the returned result.

Searching for big keys using Redis commands

If there is a pattern of big keys, for example, the prefix is cloud:msg:test, you can use a program to scan for keys that match the prefix, and then run commands to query the number of members in the key and query the key sizes to find big keys.

  • Commands for querying the number of members: LLEN, HLEN, XLEN, ZCARD, SCARD
  • Commands for querying the memory usage of keys: DEBUG OBJECT, MEMORY USAGE
CAUTION:

This method consumes a large number of computing resources. To ensure service running, do not use this method on instances with heavy service pressure.

Searching for big keys using redis-rdb-tools

redis-rdb-tools is an open-source tool for analyzing Redis RDB snapshot files. You can use it to analyze the memory usage of all keys in a Redis instance.

To use this method, you must export the RDB file of an instance on the Backups & Restorations page of the DCS console.

CAUTION:

This method does not affect service running, but is not as timely as online analysis.

Hot key analysis is not supported by DCS Redis 3.0 instances. However, you can configure alarms to detect hot keys.

  • Configure alarm rules for the Memory Usage metric of the instance nodes.

    If a node has a big key, the memory usage of the node is much higher than that of other nodes. In this case, an alarm is triggered to help you find the potentially problematic key.

  • Configure alarm rules for the Maximum Inbound Bandwidth, Maximum Outbound Bandwidth, and CPU Usage metrics of the instance nodes.

    If a node has a hot key, the bandwidth and CPU usage of the node is much higher than that of other nodes. In this case, an alarm is triggered to help you find the potentially problematic key.

Big/Hot Key Analysis and Expired Key Scan FAQs

more