【 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.
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?
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.
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.