ElasticSearch:如何读取节点/热线程输出

0yg35tkg  于 2023-03-17  发布在  ElasticSearch
关注(0)|答案(2)|浏览(77)

我在ElasticSearch中有一个数据节点,它的CPU占用率很高(99%),搜索速度很慢。使用top可以发现它的elasticsearch进程占用了所有的CPU。
我在那个节点上运行了_nodes/hot_threads API,得到了这个输出,但是我不知道如何解释它,有人能解释一下吗?

::: {warm-xxx}{XXXXXXX}{YYYYYYYY}{10.10.10.10}{10.10.10.10:9300}{aws_availability_zone=us-west-2b, data_type=warm, ml.machine_memory=64388997120, ml.max_open_jobs=20, xpack.installed=true, ml.enabled=true}
   Hot threads at 2019-12-30T23:22:24.304Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:

   44.0% (220.2ms out of 500ms) cpu usage by thread 'elasticsearch[warm-xxx][management][T#1]'
     3/10 snapshots sharing following 57 elements
       org.elasticsearch.index.engine.Engine.segmentsStats(Engine.java:831)
       org.elasticsearch.index.shard.IndexShard.segmentStats(IndexShard.java:1051)
       org.elasticsearch.action.admin.indices.stats.CommonStats.<init>(CommonStats.java:213)
       org.elasticsearch.indices.IndicesService.indexShardStats(IndicesService.java:403)
       org.elasticsearch.indices.IndicesService.statsByShard(IndicesService.java:357)
       org.elasticsearch.indices.IndicesService.stats(IndicesService.java:348)
...

   42.7% (213.4ms out of 500ms) cpu usage by thread 'elasticsearch[warm-xxx][search][T#2]'                                                                                             
     10/10 snapshots sharing following 21 elements
       org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:263)
       org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:214)
       org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)
       org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:670)
       org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:191)
       org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:471)
...
   41.8% (208.9ms out of 500ms) cpu usage by thread 'elasticsearch[warm-xxx][search][T#7]'
     10/10 snapshots sharing following 21 elements
       org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:263)
       org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:214)
       org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)
       org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:670)
       org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:191)
       org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:471)

我正在运行ElasticSearch6.8

6uxekuva

6uxekuva1#

Elasticsearch文档仍然没有解释这个API的输出。https://www.elastic.co/guide/en/elasticsearch/reference/current/cluster-nodes-hot-threads.html
但Opensearch解释了它多一点,你可以从下面的链接检查:https://opensearch.org/docs/2.6/api-reference/nodes-apis/nodes-hot-threads/
注意:两篇文章都不够好,无法理解正在发生的事情:)

0kjbasz6

0kjbasz62#

现在已经有更多的时间,因为我添加了评论,并没有答案和详细的文件,我打算写一个,我将分享一旦完成。
但到目前为止,简而言之,Elasticsearch使用各种线程池进行各种操作(搜索、索引、管理、分析等),您可以在this官方文档中找到所有线程池及其配置,即线程数和队列大小。
现在,如果您密切关注API的输出,它将告诉您节点名称、线程池名称(在您的情况下是管理和搜索)和线程编号(如T#1、t#7),以及该线程正在执行的具体操作和所需的时间,以便您了解群集中的热点。
如您的示例所示,此特定搜索的开销非常大

41.8% (208.9ms out of 500ms) cpu usage by thread 'elasticsearch[warm-xxx][search][T#7]'
     10/10 snapshots sharing following 21 elements
       org.apache.lucene.search.Weight$DefaultBulkScorer.scoreAll(Weight.java:263)
       org.apache.lucene.search.Weight$DefaultBulkScorer.score(Weight.java:214)
       org.apache.lucene.search.BulkScorer.score(BulkScorer.java:39)
       org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:670)
       org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:191)
       org.apache.lucene.search.IndexSearcher.search(IndexSearcher.java:471)

因此,您需要在应用程序中弄清楚如何使用这个搜索org.elasticsearch.search.internal.ContextIndexSearcher.search(ContextIndexSearcher.java:191),并尝试改进它。

相关问题