探究 | Elasticsearch CPU高排查思路

一、可能导致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

三、解决方案:

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

2018年04月10日 0:18于家中床前

作者:铭毅天下
转载请标明出处,原文地址:
https://blog.csdn.net/laoyang360/article/details/79874984
如果感觉本文对您有帮助,请点击‘顶’支持一下,您的支持是我坚持写作最大的动力,谢谢!

image)

  • 4
    点赞
  • 17
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

铭毅天下

和你一起,死磕Elastic!

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值