探究 | Elasticsearch CPU高排查思路

本文涉及的产品
检索分析服务 Elasticsearch 版,2核4GB开发者规格 1个月
简介: 一、可能导致ES CPU高的原因:1、复杂的query查询举例:我这边出现过200个组合wildcard query导致集群down掉的情况;2、有大量的reindex操作3、ES版本较低

二、排查思路

2.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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

三、解决方案:

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

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

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

相关实践学习
使用阿里云Elasticsearch体验信息检索加速
通过创建登录阿里云Elasticsearch集群,使用DataWorks将MySQL数据同步至Elasticsearch,体验多条件检索效果,简单展示数据同步和信息检索加速的过程和操作。
ElasticSearch 入门精讲
ElasticSearch是一个开源的、基于Lucene的、分布式、高扩展、高实时的搜索与数据分析引擎。根据DB-Engines的排名显示,Elasticsearch是最受欢迎的企业搜索引擎,其次是Apache Solr(也是基于Lucene)。 ElasticSearch的实现原理主要分为以下几个步骤: 用户将数据提交到Elastic Search 数据库中 通过分词控制器去将对应的语句分词,将其权重和分词结果一并存入数据 当用户搜索数据时候,再根据权重将结果排名、打分 将返回结果呈现给用户 Elasticsearch可以用于搜索各种文档。它提供可扩展的搜索,具有接近实时的搜索,并支持多租户。
相关文章
|
7月前
|
安全 Windows
一次简单的服务器 cpu 占用率高的快速排查实战
一次简单的服务器 cpu 占用率高的快速排查实战
|
5月前
|
Arthas 测试技术
Arthas排查生产环境CPU飚高问题
Arthas排查生产环境CPU飚高问题
Arthas排查生产环境CPU飚高问题
|
8月前
|
运维 监控 Java
内存溢出+CPU占用过高:问题排查+解决方案+复盘(超详细分析教程)
全网最全的内存溢出CPU占用过高排查文章,包含:问题出现现象+临时解决方案+复现问题+定位问题发生原因+优化代码+优化后进行压测,上线+复盘
1372 5
|
7月前
|
存储 自然语言处理 Java
Elasticsearch常见错误及如何排查错误
Elasticsearch常见错误及如何排查错误
205 0
|
3月前
|
监控 Java Linux
疯狂飙高!怎么排查CPU导致系统反应缓慢的问题?
疯狂飙高!怎么排查CPU导致系统反应缓慢的问题?
|
4月前
|
弹性计算 Linux 数据安全/隐私保护
Linux【问题记录 01】阿里云CPU使用率 100% ECS 同时连接数峰值 25k+ 问题排查无果(附阿里云重新初始化云盘详细步骤)
Linux【问题记录 01】阿里云CPU使用率 100% ECS 同时连接数峰值 25k+ 问题排查无果(附阿里云重新初始化云盘详细步骤)
125 0
|
6月前
|
Java 调度
服务器常见问题排查(一)——cpu占用高、上下文频繁切换、频繁GC
文章主要讨论了服务器中常见性能问题的一些排查思路,这篇文章主要讨论了CPU负载过高,频繁GC和频繁切换上线文这三个问题。
324 0
服务器常见问题排查(一)——cpu占用高、上下文频繁切换、频繁GC
|
7月前
|
Java 调度
CPU突然飙高系统反应慢,是怎么导致的?有什么办法排查?
面试过程中,场景类的问题更容易检测出一个开发人员的基本能力。这不,有一位小伙伴去阿里面试,第一面就遇到了关于“CPU 飙高系统反应慢怎么排查”的问题?当时这位小伙伴不知从何下手。 今天,我给大家分享一下我的解决思路。
110 0
|
8月前
|
Java
CPU飙升排查
CPU飙升排查
100 0
|
8月前
|
监控 Java
【线上问题排查】CPU100%和内存100%排查
【线上问题排查】CPU100%和内存100%排查
117 1

热门文章

最新文章