High performance is the biggest characteristic of Redis, and ensuring the performance of Redis is a necessary measure in the process of using Redis. There are a variety of factors that can cause Redis performance problems, and hot keys are one of the most common. Finding the hot Key is helpful to further solve the problem. This paper introduces the method to query the hot Key by using the new feature of Redis 4.0.

Redis 4.0 added allkey-lFU and volatile- lFU data expulsion policies. In addition, the OBJECT command can be used to obtain the access frequency of a key, as shown in the following figure.

Redis native client has also added the hotkeys option to help you quickly find hotkeys for your business.

redis-cli -h xxxxxx.com -a <password> --hotkeys
Copy the code

This article uses Redis-Benchmark to simulate a massive write scenario in a business.

The following is an example of the command output:

The summary part of the execution result is the hot Key obtained from the analysis.