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: 30queue_size: 1000
scaling
線程池中的線程數量依據一定的規則動態調整。
通過參數core
、max
,以及工作負載情況來判定線程的生命周期和數量。
通過參數keep_alive
來決定空載情況下,線程的存活時長。
配置樣例,如下:
thread_pool:warmer:core: 1max: 8keep_alive: 2m
相關資料
- Thread pools
- Watcher
- Flush API
- Translog
- Force merge API