ElasticSearch之线程池
ElasticSearch节点可用的CPU核的数量,通常可以交给ElasticSearch来自行检测和判定,另外可以在``elasticsearch.yml`中显式指定。样例如下:
node.processors: 2
如下表格中的processors即CPU核的数量。
线程池的列表
| 线程池名称 | 类型 | 线程数量 | 队列长度 | 用途 |
|---|---|---|---|---|
| generic | scaling | 一般用途。 | ||
| search | fixed | (processors * 3) / 2 + 1 |
1000 | count/search |
| search_worker | fixed | (processors * 3) / 2 + 1 |
unbounded |
count/search |
| search_throttled | fixed | 1 | 100 | count/search/suggest/get |
| search_coordination | fixed | processors / 2 |
1000 | search-related |
| get | fixed | (processors * 3) / 2 + 1 |
1000 | get |
| analyze | fixed | 1 | 16 | analyze |
| write | fixed | processors |
10000 | index/delete/update, ingest processors, and bulk requests |
| snapshot | scaling | min(5, (processors) / 2) |
snapshot/restore |
|
| snapshot_meta | scaling | min(50, (processors* 3)) |
snapshot repository metadata read |
|
| warmer | scaling | min(5, processors / 2) |
segment warm-up |
|
| refresh | scaling | min(10, processors / 2) |
refresh |
|
| fetch_shard_started | scaling | 2 * processors |
listing shard states |
|
| fetch_shard_store | scaling | 2 * processors |
listing shard stores |
|
| flush | scaling | min(5, processors / 2) |
flush/translog |
|
| force_merge | fixed | max(1, processors / 8) |
unbounded |
force merge |
| management | scaling | 5 | cluster management |
|
| system_read | fixed | min(5, processors / 2) |
read |
|
| system_write | fixed | min(5, processors / 2) |
write |
|
| system_critical_read | fixed | min(5, processors / 2) |
read |
|
| system_critical_write | fixed | min(5, processors / 2) |
write |
|
| watcher | fixed | min(5 * processors, 50) |
1000 | watch executions |
依据上述表格中的线程数量的规则,通过指定node.processors,可以推断出ElasticSearch各线程池中线程的数量。
线程池的类型
fixed
线程池中的线程数量固定,同时使用队列来缓存当前暂时无法处理的请求。
通过参数size指定线程池中线程的数量。
通过参数queue_size指定请求队列的长度,默认值为-1,表示unbounded,即为无界队列。
配置样例,如下:
thread_pool:
write:
size: 30
queue_size: 1000
scaling
线程池中的线程数量依据一定的规则动态调整。
通过参数core、max,以及工作负载情况来判定线程的生命周期和数量。
通过参数keep_alive来决定空载情况下,线程的存活时长。
配置样例,如下:
thread_pool:
warmer:
core: 1
max: 8
keep_alive: 2m
相关资料
本文来自博客园,作者:jackieathome,转载请注明原文链接:https://www.cnblogs.com/jackieathome/p/17863282.html

浙公网安备 33010602011771号