elasticsearch8.3容器单机版搭建
基于docker-compose快速启动
1 | services: |
curl查看es-node thread_pool
curl -s -q --location --request GET 'http://47.96.130.181:19200/_nodes/stats/thread_pool' \
--header 'Authorization: Basic xxxx' |python3 -m json.tool |grep search -A 5
/_nodes/stats/thread_pool.search 如何自定义
thread_pool.search.queue_size,
thread_pool.get.queue_size,
thread_pool.search_worker.queue_size,
thread_pool.analyze.queue_size,
thread_pool.write.queue_size,
thread_pool.search.size,
thread_pool.system_read.queue_size]?"
thread_pool
Elasticsearch 8.3 中 _nodes/stats/thread_pool.search 里的一些线程池参数是否可以修改,以及如何自定义。我们来仔细分析。
1.线程池参数概念
Elasticsearch 的线程池(thread pool)管理不同类型的任务,例如:
| 线程池类型 | 用途 |
|---|---|
search |
搜索请求执行 |
get |
GET 请求执行 |
write |
索引/写入请求 |
bulk |
批量操作 |
analyze |
分词分析 |
system_read |
系统内部读操作 |
每个线程池通常有几个关键参数:
size:线程池中固定线程数或动态计算的核心线程数。queue_size:队列长度,即当线程全部被占用时,允许等待的请求数量。keep_alive:非核心线程空闲多久会被回收(仅部分线程池可配置)。
2.Elasticsearch 配置方式
注意:ES8.x 对线程池参数可配置性有限:
线程池 类型为
fixed的(固定线程数):size和queue_size可以在elasticsearch.yml中修改,或者通过 动态 cluster setting 修改(大部分为静态,需要重启)。
线程池 类型为
scaling(可扩展):size代表初始线程数,Elasticsearch 会根据负载自动扩展到最大值,队列长度通常可配置。
有些线程池参数 不能在运行时修改,尤其是系统线程池或内部线程池。
3.验证参数是否生效
1 | GET /_nodes/stats/thread_pool/search |
输出类似:
1 | { |
threads→ 当前线程池大小queue→ 当前排队请求数largest→ 历史最大线程数rejected→ 被拒绝请求数量