High performance is the most prominent feature of Redis. Robust Redis performance is crucial to ensure the service availability. A reduced Redis performance can be caused by multiple reasons. The hotkey issue is one of the most common reasons. The discovery of hotkeys is the first step to improve Redis performance. This topic describes how to use the new features of Redis 4.0 to discover the hotkeys.
Redis 4.0 added two data eviction strategies: allkey-lfu and volatile-lfu. You can also run the OBJECT command to obtain the access frequency of a specific key, as shown in the following figure.
The native Redis client also added the --hotkeys option to help you discover hotkeys in your business.
- You have activated an Elastic Compute Service (ECS) instance that can connect to an ApsaraDB for Redis instance.
- You have installed a Redis server whose version is later than 4.0 on the ECS instance.
Note You can use redis-cli after Redis is installed on the ECS instance.
- The maxmemory-policy parameter of the ApsaraDB for Redis instance is set to volatile-lfu or allkeys-lfu.
Note For more information about how to modify the parameters, see Parameter overview and configuration guide.
- You can use the following command to query the hotkeys when the ApsaraDB for Redis
instance have running workloads.
redis-cli -h r-***************.redis.rds.aliyuncs.com -a <password> --hotkeysNote This topic uses redis-benchmark to simulate a scenario that features a high volume of writes.
Table 1. Option descriptions Option Description -h Specifies the endpoint of an ApsaraDB for Redis instance. -a Specifies the password of an ApsaraDB for Redis instance. --hotkeys Used to query hotkeys.
The following example shows the result of running this command.
The summary part in the result displays the hotkeys.