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

配置项作用 #

search.max_open_pit_context 配置项控制允许同时打开的 Point In Time (PIT) 上下文的最大数量。PIT 上下文用于查询历史数据状态,此配置限制并发 PIT 上下文数量以防止资源耗尽。

配置项类型 #

该配置项为动态配置,可以在运行时通过集群设置 API 进行修改。

默认值 #

300

是否必需 #

可选配置项(有默认值)

取值范围 #

0 ~ 正无穷

配置格式 #

# 默认配置
search.max_open_pit_context: 300

# 增加并发数
search.max_open_pit_context: 500

# 减少并发数
search.max_open_pit_context: 100

# 限制 PIT 使用
search.max_open_pit_context: 50

相关配置项 #

配置项默认值说明
search.max_open_pit_context300最大 PIT 上下文数
search.max_keep_alive24h最大保活时间
point_in_time.max_keep_alive24hPIT 最大保活时间

工作原理 #

PIT 上下文管理:

┌─────────────────────────────────────────────────────────────────┐
│                    PIT 上下文管理                                 │
└─────────────────────────────────────────────────────────────────┘

创建 PIT 上下文请求
    │
    ▼
检查当前 PIT 上下文数
    │
    ├── 当前数量 < max_open_pit_context
    │   │
    │   └── 允许创建
    │
    └── 当前数量 >= max_open_pit_context
        │
        └── 拒绝创建,返回错误

使用场景 #

1. 默认配置(推荐) #

search.max_open_pit_context: 300

适用于大多数集群配置。

2. 大量历史查询 #

search.max_open_pit_context: 500

适用场景:

  • 频繁历史数据查询
  • 多用户并发 PIT 查询
  • 需要更多并发

3. 资源受限 #

search.max_open_pit_context: 100

适用场景:

  • 资源受限环境
  • PIT 使用较少
  • 控制 JVM 堆内存使用

4. 限制 PIT 使用 #

search.max_open_pit_context: 50

适用场景:

  • 不鼓励使用 PIT
  • 保护系统资源
  • 强制使用快照

推荐设置建议 #

场景推荐值说明
默认300标准配置
高并发 PIT500-1000大量历史查询
资源受限100-200限制使用
禁用 PIT0禁用 PIT 功能

监控建议 #

# 查看当前配置
GET /_cluster/settings?filter_path=*.search.max_open_pit_context

# 查看 PIT 上下文
GET /_nodes/stats/indices/search?filter_path=**.pit

# 查看 PIT 统计
GET /_nodes/stats/indices/search?filter_path=**.pit_total

动态配置示例 #

# 更新集群配置
PUT /_cluster/settings
{
  "transient": {
    "search.max_open_pit_context": 500
  }
}

# 临时限制 PIT 使用
PUT /_cluster/settings
{
  "transient": {
    "search.max_open_pit_context": 100
  }
}

注意事项 #

  1. 动态更新:此配置为动态配置,可在线修改
  2. 资源消耗:PIT 上下文消耗 JVM 堆内存
  3. 拒绝请求:达到上限后新的 PIT 请求会被拒绝
  4. 与 max_keep_alive 配合:两个配置共同控制资源使用
  5. 内存监控:增加限制前应监控 JVM 堆内存使用