Meaning and Calculation Methods of Some Fields in the TiDB System View TIDB_HOT_REGIONS

Note:
This topic has been translated from a Chinese forum by GPT and might contain errors.

Original topic: TIDB 系统视图TIDB_HOT_REGIONS中部分字段含义&计算方式

| username: residentevil

【 TiDB Usage Environment】Production Environment
【 TiDB Version】v6.1.7
【Encountered Problem: Problem Description and Impact】What are the specific meanings of the MAX_HOT_DEGREE and FLOW_BYTES fields in the TIDB_HOT_REGIONS table in the information_schema database? I hope to obtain the regions with hotspots from this table and then perform the corresponding migration.

| username: 昵称想不起来了 | Original post link

  • MAX_HOT_DEGREE: The maximum hot degree of the Region.
  • FLOW_BYTES: The number of bytes written and read in the Region.
| username: residentevil | Original post link

The explanation is quite clear. It seems that we can identify hotspot REGIONS using this method. If we know which REGION it is, can we manually trigger the REGION to split?

| username: 有猫万事足 | Original post link

The algorithm for the hot degree is quite interesting.

First, regions are logically divided into buckets.

Then TiKV reports six metrics for each bucket: read bytes, read keys, read QPS, written bytes, written keys, and written QPS.

After reporting to PD, these metrics are compared with a static baseline. The specific settings for the static baseline can be found at

The algorithm is located at

As you can see, if any of the three read/write metrics exceed the baseline value, the hot degree of the current bucket is incremented by 1; similarly, if none of the metrics exceed the baseline value, the hot degree is decremented by 1. Additionally, the hot degree of a single bucket has an upper and lower limit, ranging from [20, -20], and it will not fluctuate beyond this range. The hot degree of a region is the sum of the hot degrees of the logical buckets.

My understanding is limited, but this is roughly the idea.

| username: Fly-bird | Original post link

READ_BYTES: The estimated amount of data read in a Region within one heartbeat cycle, measured in bytes. From this, it can be seen that Regions with particularly large values are experiencing hotspots.

| username: residentevil | Original post link

The analysis is very thorough. Next, I’ll look into how to balance the hotspot regions.

| username: 大飞哥online | Original post link

Got it