📣 极限科技诚招搜索运维工程师(Elasticsearch/Easysearch)- 全职/北京 👉 : 立即申请加入

配置项作用 #

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.core1核心线程数
thread_pool.fetch_shard_started.max2 * processors最大线程数
thread_pool.fetch_shard_started.keep_alive5m线程保活时间
thread_pool.fetch_shard_store.max2 * 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 核心数推荐核心线程推荐最大线程说明
418小型节点
8116中型节点
161-232大型节点
32+264高性能节点

监控建议 #

# 查看线程池状态
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_startedfetch_shard_store
用途分片启动后获取分片存储文件获取
触发时机分片变为启动状态打开分片存储时
数据类型段元数据段文件数据
默认 max2 * processors2 * processors

注意事项 #

  1. 静态配置:修改需要重启节点
  2. I/O 密集型:分片获取操作消耗大量磁盘 I/O
  3. 网络敏感:远程获取依赖网络带宽
  4. 与恢复配置配合:配合 cluster.routing.allocation.node_concurrent_recoveries 使用
  5. 最大线程数较大:max 为 CPU 核心数的 2 倍
  6. 在低峰期执行:大量分片恢复会影响系统性能