探究 | Elasticsearch CPU高排查思路

本文涉及的产品
Elasticsearch Serverless通用抵扣包,测试体验金 200元
简介: Elasticsearch CPU高排查思路的探究思路。

一、可能导致ES CPU高的原因:

1、复杂的query查询

举例:我这边出现过200个组合wildcard query导致集群down掉的情况;

2、有大量的reindex操作

3、ES版本较低

二、排查思路

1、业务场景排查

问自己几个问题?

  • 1)集群中数据类型是怎么样的?
  • 2)集群中有多少数据?
  • 3)集群中有多少节点数、分片数?
  • 4)当前集群索引和检索的速率如何?
  • 5)当前在执行哪种类型的查询或者其他操作?

2、建议Htop观察,结合ElaticHQ 观察CPU曲线

3、CPU高的时候,建议看一下ES节点的日志,看看是不是有大量的GC。

4、查看hot_threads。

GET _nodes/hot_threads

::: {test}{ikKuXkFvRc-qFCqG99smGg}{VE-uqoiARoONJwomfPwRBw}{127.0.0.1}{127.0.0.1:9300}{ml.machine_memory=8481566720, ml.max_open_jobs=20, ml.enabled=true}
   Hot threads at 2018-04-09T15:58:21.117Z, interval=500ms, busiestThreads=3, ignoreIdleThreads=true:

    0.0% (0s out of 500ms) cpu usage by thread 'Attach Listener'
     unique snapshot
     unique snapshot
     unique snapshot
     unique snapshot
     unique snapshot
     unique snapshot
     unique snapshot
     unique snapshot
     unique snapshot
     unique snapshot

三、解决方案:

3.1、集群负载高,增加新节点以缓解负载。

3.2、增加堆内存到系统内存的1半,最大31GB(理论上线32GB).

如果机器内存不够,那就加大内存吧。
https://github.com/elastic/elasticsearch/issues/10437
https://discuss.elastic.co/t/es-high-cpu-usage-when-idle/87950/4

3.3、插入数据的时候,副本数设置为0.

分片数不可以修改,副本数是可以修改的。

注意:分片过多,会导致:堆内存压力大。

3.4、配置优化

Force all memory to be locked, forcing the JVM to never swap
bootstrap.mlockall: true
Threadpool Settings
Search pool
threadpool.search.type: fixed
threadpool.search.size: 20
threadpool.search.queue_size: 200
Bulk pool
threadpool.bulk.type: fixed
threadpool.bulk.size: 60
threadpool.bulk.queue_size: 3000
Index pool
threadpool.index.type: fixed
threadpool.index.size: 20
threadpool.index.queue_size: 1000
Indices settings
indices.memory.index_buffer_size: 30%
indices.memory.min_shard_index_buffer_size: 12mb
indices.memory.min_index_buffer_size: 96mb
Cache Sizes
indices.fielddata.cache.size: 30%
#indices.fielddata.cache.expire: 6h #will be depreciated & Dev recomend not to use it
indices.cache.filter.size: 30%
#indices.cache.filter.expire: 6h #will be depreciated & Dev recomend not to use it
Indexing Settings for Writes
index.refresh_interval: 30s
#index.translog.flush_threshold_ops: 50000
#index.translog.flush_threshold_size: 1024mb
index.translog.flush_threshold_period: 5m
index.merge.scheduler.max_thread_count: 1

参考:https://github.com/elastic/elasticsearch/issues/4288


作者:铭毅天下
转载请标明出处,原文地址:
https://blog.csdn.net/laoyang360/article/details/79874984

相关实践学习
以电商场景为例搭建AI语义搜索应用
本实验旨在通过阿里云Elasticsearch结合阿里云搜索开发工作台AI模型服务,构建一个高效、精准的语义搜索系统,模拟电商场景,深入理解AI搜索技术原理并掌握其实现过程。
ElasticSearch 最新快速入门教程
本课程由千锋教育提供。全文搜索的需求非常大。而开源的解决办法Elasricsearch(Elastic)就是一个非常好的工具。目前是全文搜索引擎的首选。本系列教程由浅入深讲解了在CentOS7系统下如何搭建ElasticSearch,如何使用Kibana实现各种方式的搜索并详细分析了搜索的原理,最后讲解了在Java应用中如何集成ElasticSearch并实现搜索。  
相关文章
|
监控 Java 索引
cpu使用率过高和jvm old占用过高排查过程
cpu使用率过高和jvm old占用过高排查过程
354 2
|
安全 Windows
一次简单的服务器 cpu 占用率高的快速排查实战
一次简单的服务器 cpu 占用率高的快速排查实战
|
Arthas 测试技术
Arthas排查生产环境CPU飚高问题
Arthas排查生产环境CPU飚高问题
299 0
Arthas排查生产环境CPU飚高问题
|
小程序 JavaScript Java
【Java】服务CPU占用率100%,教你用jstack排查定位
本文详细讲解如何使用jstack排查定位CPU高占用问题。首先介绍jstack的基本概念:它是诊断Java应用程序线程问题的工具,能生成线程堆栈快照,帮助找出程序中的瓶颈。接着,文章通过具体步骤演示如何使用`top`命令找到高CPU占用的Java进程及线程,再结合`jstack`命令获取堆栈信息并进行分析,最终定位问题代码。
1307 2
【Java】服务CPU占用率100%,教你用jstack排查定位
|
监控 安全 算法
在Linux中,cpu使用率过高可能是什么原因引起的?排查思路是什么?
在Linux中,cpu使用率过高可能是什么原因引起的?排查思路是什么?
|
消息中间件 Java 调度
一次线上服务CPU100%的排查过程
文章记录了一次线上服务CPU使用率达到100%的排查过程,通过使用top命令和jstack工具确定了导致高CPU使用的线程,并分析了Disruptor组件的不当配置是问题原因,通过修改组件的策略成功解决了问题。
293 0
|
存储 自然语言处理 Java
Elasticsearch常见错误及如何排查错误
Elasticsearch常见错误及如何排查错误
802 0
靠这三步就能排查CPU占用100%?
靠这三步就能排查CPU占用100%?
460 0
|
存储 监控 安全
最近几个典型 Elasticsearch 线上易出错难排查问题汇集,咱们得避免!
最近几个典型 Elasticsearch 线上易出错难排查问题汇集,咱们得避免!
|
缓存 弹性计算 监控
云服务器 CPU 使用率高的问题排查与优化
云服务器 CPU 使用率高的问题排查与优化
906 0