配置项作用 #
thread_pool.fetch_shard_started 相关配置项控制用于执行分片启动后获取操作的线程池。当分片启动后需要从其他节点获取数据时使用此线程池。该线程池采用伸缩线程池类型。
配置项类型 #
该配置项为静态配置,需要在启动时设置,修改后需要重启节点才能生效。
默认值 #
thread_pool.fetch_shard_started.core: 1
thread_pool.fetch_shard_started.max: 2 * allocatedProcessors
计算公式: 2 * CPU 核心数
thread_pool.fetch_shard_started.keep_alive: 5m
是否必需 #
可选配置项(有默认值)
配置格式 #
# 默认配置(假设 CPU 核心数为 8)
thread_pool.fetch_shard_started.core: 1
thread_pool.fetch_shard_started.max: 16
thread_pool.fetch_shard_started.keep_alive: 5m
# 增加最大线程数
thread_pool.fetch_shard_started.core: 2
thread_pool.fetch_shard_started.max: 32
# 减少最大线程数
thread_pool.fetch_shard_started.core: 1
thread_pool.fetch_shard_started.max: 8
相关配置项 #
| 配置项 | 默认值 | 说明 |
|---|---|---|
thread_pool.fetch_shard_started.core | 1 | 核心线程数 |
thread_pool.fetch_shard_started.max | 2 * processors | 最大线程数 |
thread_pool.fetch_shard_started.keep_alive | 5m | 线程保活时间 |
thread_pool.fetch_shard_store.max | 2 * processors | 分片存储获取最大线程数 |
线程池类型 #
类型: SCALING (伸缩线程池)
特点:
- 核心线程数始终保持
- 根据负载动态扩展
- 空闲线程超时后回收
- 最大线程数为 CPU 核心数的 2 倍
工作原理 #
分片启动获取操作处理流程:
┌─────────────────────────────────────────────────────────────────┐
│ 分片启动获取处理 │
└─────────────────────────────────────────────────────────────────┘
分片启动后需要获取数据
│
├── 副本分片恢复
├── 分片迁移
├── 节点恢复
└── 数据同步
│
▼
检查线程池状态
│
├── 活动线程 < core
│ │
│ └── 创建/使用核心线程处理
│
├── core <= 活动线程 < max
│ │
│ └── 扩展临时线程处理
│
└── 活动线程 >= max
│
└── 加入队列等待
默认值计算 #
max = 2 * allocatedProcessors
示例:
CPU 核心数 = 4
max = 2 * 4 = 8
CPU 核心数 = 8
max = 2 * 8 = 16
CPU 核心数 = 16
max = 2 * 16 = 32
CPU 核心数 = 32
max = 2 * 32 = 64
使用场景 #
1. 默认配置(推荐) #
thread_pool.fetch_shard_started.core: 1
thread_pool.fetch_shard_started.max: 16
thread_pool.fetch_shard_started.keep_alive: 5m
适用于大多数集群配置。
2. 高并发恢复场景 #
thread_pool.fetch_shard_started.core: 2
thread_pool.fetch_shard_started.max: 32
thread_pool.fetch_shard_started.keep_alive: 5m
适用场景:
- 大规模集群
- 频繁节点故障恢复
- 快速分片迁移需求
3. 资源受限 #
thread_pool.fetch_shard_started.core: 1
thread_pool.fetch_shard_started.max: 8
thread_pool.fetch_shard_started.keep_alive: 5m
适用场景:
- 资源受限环境
- 网络带宽有限
- 限制并发恢复
推荐设置建议 #
| CPU 核心数 | 推荐核心线程 | 推荐最大线程 | 说明 |
|---|---|---|---|
| 4 | 1 | 8 | 小型节点 |
| 8 | 1 | 16 | 中型节点 |
| 16 | 1-2 | 32 | 大型节点 |
| 32+ | 2 | 64 | 高性能节点 |
监控建议 #
# 查看线程池状态
GET /_cat/thread_pool/fetch_shard_started?v
# 查看详细统计
GET /_nodes/stats/thread_pool/fetch_shard_started
# 查看分片恢复状态
GET /_cat/recovery?v
# 查看节点网络使用情况
GET /_nodes/stats/transport
与 fetch_shard_store 的区别 #
| 特性 | fetch_shard_started | fetch_shard_store |
|---|---|---|
| 用途 | 分片启动后获取 | 分片存储文件获取 |
| 触发时机 | 分片变为启动状态 | 打开分片存储时 |
| 数据类型 | 段元数据 | 段文件数据 |
| 默认 max | 2 * processors | 2 * processors |
注意事项 #
- 静态配置:修改需要重启节点
- I/O 密集型:分片获取操作消耗大量磁盘 I/O
- 网络敏感:远程获取依赖网络带宽
- 与恢复配置配合:配合
cluster.routing.allocation.node_concurrent_recoveries使用 - 最大线程数较大:max 为 CPU 核心数的 2 倍
- 在低峰期执行:大量分片恢复会影响系统性能





