Skip to content

Commit 34be067

Browse files
authored
scheduler: network slow store scheduler enhancement (#22269)
1 parent 8a6fe4a commit 34be067

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

best-practices/pd-scheduling-best-practices.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,9 @@ If a TiKV node fails, PD defaults to setting the corresponding node to the **dow
297297

298298
Practically, if a node failure is considered unrecoverable, you can immediately take it offline. This makes PD replenish replicas soon in another node and reduces the risk of data loss. In contrast, if a node is considered recoverable, but the recovery cannot be done in 30 minutes, you can temporarily adjust `max-store-down-time` to a larger value to avoid unnecessary replenishment of the replicas and resources waste after the timeout.
299299

300-
In TiDB v5.2.0, TiKV introduces the mechanism of slow TiKV node detection. By sampling the requests in TiKV, this mechanism works out a score ranging from 1 to 100. A TiKV node with a score higher than or equal to 80 is marked as slow. You can add [`evict-slow-store-scheduler`](/pd-control.md#scheduler-show--add--remove--pause--resume--config--describe) to detect and schedule slow nodes. If only one TiKV is detected as slow, and the slow score reaches the limit (80 by default), the Leader in this node will be evicted (similar to the effect of `evict-leader-scheduler`).
300+
Starting from TiDB v5.2.0, TiKV introduces a mechanism to detect slow-disk nodes. By sampling the requests in TiKV, this mechanism works out a score ranging from 1 to 100. A TiKV node with a score higher than or equal to 80 is marked as slow. You can add [`evict-slow-store-scheduler`](/pd-control.md#scheduler-show--add--remove--pause--resume--config--describe) to schedule slow nodes. If only one TiKV node is detected as slow, and its slow score reaches the limit (80 by default), the Leaders on that node will be evicted (similar to the effect of `evict-leader-scheduler`).
301+
302+
Starting from v8.5.5 and v9.0.0, TiKV introduces a mechanism to detect slow-network nodes. Similar to slow-disk node detection, this mechanism identifies slow nodes by probing network latency between TiKV nodes and calculating a score. You can enable this mechanism using [`enable-network-slow-store`](/pd-control.md#scheduler-config-evict-slow-store-scheduler).
301303

302304
> **Note:**
303305
>

pd-control.md

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,7 @@ Usage:
941941
>> scheduler config evict-leader-scheduler // Display the stores in which the scheduler is located since v4.0.0
942942
>> scheduler config evict-leader-scheduler add-store 2 // Add leader eviction scheduling for store 2
943943
>> scheduler config evict-leader-scheduler delete-store 2 // Remove leader eviction scheduling for store 2
944-
>> scheduler add evict-slow-store-scheduler // When there is one and only one slow store, evict all Region leaders of that store
944+
>> scheduler add evict-slow-store-scheduler // Automatically detect slow-disk or slow-network nodes and evict all Region leaders from those nodes when specific conditions are met
945945
>> scheduler remove grant-leader-scheduler-1 // Remove the corresponding scheduler, and `-1` corresponds to the store ID
946946
>> scheduler pause balance-region-scheduler 10 // Pause the balance-region scheduler for 10 seconds
947947
>> scheduler pause all 10 // Pause all schedulers for 10 seconds
@@ -965,6 +965,44 @@ The state of the scheduler can be one of the following:
965965
- `pending`: the scheduler cannot generate scheduling operators. For a scheduler in the `pending` state, brief diagnostic information is returned. The brief information describes the state of stores and explains why these stores cannot be selected for scheduling.
966966
- `normal`: there is no need to generate scheduling operators.
967967
968+
### `scheduler config evict-slow-store-scheduler`
969+
970+
The `evict-slow-store-scheduler` limits PD from scheduling Leaders to abnormal TiKV nodes and actively evicts Leaders when necessary, thereby reducing the impact of slow nodes on the cluster when TiKV nodes experience disk I/O or network jitter.
971+
972+
#### Slow-disk nodes
973+
974+
Starting from v6.2.0, TiKV reports a `SlowScore` in store heartbeats to PD. This score is calculated based on disk I/O conditions and ranges from 1 to 100. A higher value indicates a higher possibility of disk performance anomalies on that node.
975+
976+
For slow-disk nodes, the detection on TiKV and the scheduling via `evict-slow-store-scheduler` on PD are enabled by default, which means no additional configuration is required.
977+
978+
#### Slow-network nodes
979+
980+
Starting from v8.5.5 and v9.0.0, TiKV supports reporting a `NetworkSlowScore` in store heartbeats to PD. It is calculated based on network detection results and helps identify slow nodes experiencing network jitter. The score ranges from 1 to 100, where a higher value indicates a higher possibility of network anomalies.
981+
982+
For compatibility and resource consumption considerations, the detection and scheduling of slow-network nodes are disabled by default. To enable them, configure both of the following:
983+
984+
1. Enable the PD scheduler to handle slow-network nodes:
985+
986+
```bash
987+
scheduler config evict-slow-store-scheduler set enable-network-slow-store true
988+
```
989+
990+
2. On TiKV, set the [`raftstore.inspect-network-interval`](/tikv-configuration-file.md#inspect-network-interval-new-in-v855-and-v900) configuration item to a value greater than `0` to enable network detection.
991+
992+
#### Recovery time control
993+
994+
You can specify how long a slow node must remain stable before it is considered recovered by using the `recovery-duration` parameter.
995+
996+
Example:
997+
998+
```bash
999+
>> scheduler config evict-slow-store-scheduler
1000+
{
1001+
"recovery-duration": "1800" // 30 minutes
1002+
}
1003+
>> scheduler config evict-slow-store-scheduler set recovery-duration 600
1004+
```
1005+
9681006
### `scheduler config balance-leader-scheduler`
9691007
9701008
Use this command to view and control the `balance-leader-scheduler` policy.

tikv-configuration-file.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -289,6 +289,13 @@ This document only describes the parameters that are not included in command-lin
289289
+ Sets the size of the connection pool for service and forwarding requests to the server. Setting it to too small a value affects the request latency and load balancing.
290290
+ Default value: `4`
291291

292+
### `inspect-network-interval` <span class="version-mark">New in v8.5.5 and v9.0.0</span>
293+
294+
+ Controls the interval at which the TiKV HealthChecker actively performs network detection to PD and other TiKV nodes. TiKV calculates a `NetworkSlowScore` based on the network detection results and reports the network status of slow nodes to PD.
295+
+ Setting this value to `0` disables the network detection. Setting it to a smaller value increases the detection frequency, which helps detect network jitter more quickly, but it also consumes more network bandwidth and CPU resources.
296+
+ Default value: `100ms`
297+
+ Value range: `0` or `[10ms, +∞)`
298+
292299
## readpool.unified
293300

294301
Configuration items related to the single thread pool serving read requests. This thread pool supersedes the original storage thread pool and coprocessor thread pool since the 4.0 version.

0 commit comments

Comments
 (0)