# High CPU usage after GC?

**URL:** https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429
**Category:** Elasticsearch
**Created:** [March 5, 2018, 3:03am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429 "2018-03-05T03:03:13Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![uLan](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@uLan](https://discuss.elastic.co/u/uLan)
#### Post date: [March 5, 2018, 3:03am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/1 "2018-03-05T03:03:13Z")

</div>

I got alerted that our CPU usage is high and according to some metrics elasticsearch is consuming cpu. This was the last log of elasticsearch, but it's still working fine though

```auto
[INFO][o.e.m.j.JvmGcMonitorService] [iJXOMG0] [gc][2923498] overhead, spent [261ms] collecting in the last [1s]

```

Shortly after this, the alert triggered

Another thing is that the last time this log showed the number seems to be small

```auto
[o.e.m.j.JvmGcMonitorService] [iJXOMG0] [gc][304] overhead, spent [272ms] collecting in the last [1s]

```

How could I lower down the CPU usage?

Elasticsearch is running on docker and I have set `ES_JAVA_OPTS: "-Xmx512m -Xms512m"`

---

<div class="post-metadata">

### Author: ![Ben96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben96/32/28334_2.png) [@Ben96](https://discuss.elastic.co/u/Ben96)
#### Post date: [March 5, 2018, 7:50am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/2 "2018-03-05T07:50:58Z")

</div>

Is your Elasticsearch Instance is running as Master/Client & Data in the same container ?

Because 512Mb is really not enought to run a one node ELK Stack.

To be safe in you case, put at least 2G for the container.

Edit : May you have to increase your CPU's

---

<div class="post-metadata">

### Author: ![uLan](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@uLan](https://discuss.elastic.co/u/uLan)
#### Post date: [March 5, 2018, 8:08am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/3 "2018-03-05T08:08:46Z")

</div>

Yes it is. I could increase the heap size but the issue here though is that it was consuming almost 0% cpu before this

 ![Screenshot%20from%202018-03-05%2016-07-33](https://us1.discourse-cdn.com/elastic/original/3X/6/4/64831b878080b0f4a258ec89e402d9dd27a543c5.png)

---

<div class="post-metadata">

### Author: ![Ben96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben96/32/28334_2.png) [@Ben96](https://discuss.elastic.co/u/Ben96)
#### Post date: [March 5, 2018, 8:30am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/4 "2018-03-05T08:30:36Z")

</div>

Mhm, what were the last tasks elastic run ?

Looks something happen to consuming from 0% to 50% AVG.

Log's aren't tell what kind of event could be the fault ? (Execpt 2 lines)

---

<div class="post-metadata">

### Author: ![uLan](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@uLan](https://discuss.elastic.co/u/uLan)
#### Post date: [March 6, 2018, 3:44am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/5 "2018-03-06T03:44:22Z")

</div>

How could I know that?

---

<div class="post-metadata">

### Author: ![Ben96](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ben96/32/28334_2.png) [@Ben96](https://discuss.elastic.co/u/Ben96)
#### Post date: [March 6, 2018, 9:39am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/6 "2018-03-06T09:39:20Z")

</div>

You could get more information from Elastic logs, at leasts more details

---

<div class="post-metadata">

### Author: ![uLan](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@uLan](https://discuss.elastic.co/u/uLan)
#### Post date: [March 6, 2018, 10:04am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/7 "2018-03-06T10:04:36Z")

</div>

Doesn't the logs go out into `STDOUT`? If so then the last logs of elasticsearch are the one I have posted originally. If there is a different file that elasticsearch logs into then I would appreciate it if you could help me find it.

---

<div class="post-metadata">

### Author: ![uLan](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@uLan](https://discuss.elastic.co/u/uLan)
#### Post date: [March 6, 2018, 10:08am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/8 "2018-03-06T10:08:45Z")

</div>

This is the contents of my log4j2 file

```auto
status = error

appender.console.type = Console
appender.console.name = console
appender.console.layout.type = PatternLayout
appender.console.layout.pattern = [%d{ISO8601}][%-5p][%-25c{1.}] %marker%m%n

rootLogger.level = info
rootLogger.appenderRef.console.ref = console

```

This means that the logs are output into the console right?

---

<div class="post-metadata">

### Author: ![uLan](https://avatars.discourse-cdn.com/v4/letter/u/bb73d2/32.png) [@uLan](https://discuss.elastic.co/u/uLan)
#### Post date: [March 9, 2018, 3:39am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/9 "2018-03-09T03:39:14Z")

</div>

Hi, I really need help on this. I could probably just restart my elasticsearch instance to solve this problem but I want to know what caused this.

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)
#### Post date: [April 6, 2018, 3:39am UTC](https://discuss.elastic.co/t/high-cpu-usage-after-gc/122429/10 "2018-04-06T03:39:18Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
