这个报错还需了解Elasticsearch的Thread Pool即线程池
每个Elasticsearch节点都拥有好几个线程池用于增强性能,其中很多线程池也带有队列,允许将一些事件放入队列而不是丢弃。
通过 curl -XGET http://xxxx:9200/_nodes/stats/thread_pool?pretty 查看各个线程池的状态
比较重要的线程池有: generic
用于常规操作,例如后台节点发现。Thread pool type is cached. index
用于index/delete操作. Thread pool type is fixed,大小是CPU核心数,队列大小是200 search
用于计算和搜索操作。Thread pool type is fixed,大小是 可用CPU核心数*3/2+1,队列大小是1000 suggest
用于suggest操作。Thread pool type is fixed,大小是可用CPU核心数,队列大小是1000 get
用于get操作。Thread pool type is fixed,大小是可用CPU核心数,队列大小是1000 bulk
用于bulk操作。Thread pool type is fixed,大小是可用CPU核心数,队列大小是50
percolate
用于percolate操作。Thread pool type is fixed,大小是可用CPU核心数,队列大小是1000 snapshot
用于快照和恢复操作。Thread pool type is scaling,维持5m的keep-alive,线程池大小是 min(5,可用CPU核心数/2),即如果CPU核心数是4,那么线程池大小就是4/2=2, 如果CPU核心数是32,那么线程池大小就是5 warmer
用于segment warm-up操作。Thread pool type is scaling,保持5m的keep-alive,线程池大小是 min(5,可用CPU核心数/2),即如果CPU核心数是4,那么线程池大小就是4/2=2, 如果CPU核心数是32,那么线程池大小就是5 refresh
用于refresh操作。Thread pool type is scaling,保持5m的keep-alive,线程池大小是 min(10,可用CPU核心数/2),即如果CPU核心数是4,那么线程池大小就是4/2=2, 如果CPU核心数是32,那么线程池大小就是5
listener
主要用于当listener threaded 设置为true时,java 客户端执行操作。Thread pool type is scaling,保持5m的keep-alive,线程池大小是 min(10,可用CPU核心数/2),即如果CPU核心数是4,那么线程池大小就是4/2=2, 如果CPU核心数是32,那么线程池大小就是5
如果想要改变某个线程池的默认值可以这样:
1
2
3
threadpool:
index:
size: 30
或者写成 threadpool.index.size: 30
Thread pool types cached
cached线程池不是一个绑定的线程池,当有待处理的请求时cached线程会衍生出一个线程。这种线程池是为了防止提交到线程池中的请求被阻断或者拒绝。这种线程池中没有用的线程会在5m左右的keep alive后终止。cached类型线程池保留给generic线程池
keep_alive 参数决定一个线程没事情做时应该在线程池中停留多长时间