# Main problem with garbage collector

**URL:** <https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656>\
**Category:** Elasticsearch\
**Created:** [July 2, 2021, 2:31pm UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656 "2021-07-02T14:31:18Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![angelogabeira](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@angelogabeira](https://discuss.elastic.co/u/angelogabeira)\
**Post date:** [July 2, 2021, 2:31pm UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/1 "2021-07-02T14:31:18Z")

</div>

guys, I really need help. I've researched a lot on the internet but I couldn't help myself.  
I have an ELK stack with an **elasticsearch 6.5** server, running for 3 years. lately i have had a lot of problem with ingesting data from logstash to elastic, it has errors.  
the **server has 64gb of ram and elastic heapsize is 48gb.**

**in my elasticseach.log file I have the following error:**  
[2021-07-02T11:25:29,501][INFO][o.e.m.j.JvmGcMonitorService] [jRaE4Ys] [gc][1548814] overhead, spent [278ms] collecting in the last [1s]  
[2021-07-02T11:25:32,548][INFO][o.e.m.j.JvmGcMonitorService] [jRaE4Ys] [gc][1548817] overhead, spent [284ms] collecting in the last [1s]

**it occurs every second**

**in my GC garbage collector log, I get this error:**

: 991400K-\>87772K(996800K), 0.0555702 secs] 28322834K-\>27477579K(50220928K), 0.0558269 secs] [Times: user=0.58 sys=0.00, real=0.05 secs]  
2021-07-02T11:28:04.998-0300: 1564168.407: Total time for which application threads were stopped: 0.0615021 seconds, Stopping threads took: 0.0026259 seconds  
2021-07-02T11:28:05.350-0300: 1564168.759: [GC (Allocation Failure) 2021-07-02T11:28:05.350-0300: 1564168.759: [ParNew  
Desired survivor size 56688640 bytes, new threshold 1 (max 6)

- age 1: 64528552 bytes, 64528552 total
- age 2: 45103376 bytes, 109631928 total  
: 973852K-\>110720K(996800K), 0.0488516 secs] 28363659K-\>27510347K(50220928K), 0.0491062 secs] [Times: user=0.59 sys=0.00, real=0.05 secs]  
2021-07-02T11:28:05.399-0300: 1564168.808: Total time for which application threads were stopped: 0.0529833 seconds, Stopping threads took: 0.0004834 seconds  
2021-07-02T11:28:05.702-0300: 1564169.112: [GC (Allocation Failure) 2021-07-02T11:28:05.702-0300: 1564169.112: [ParNew  
Desired survivor size 56688640 bytes, new threshold 1 (max 6)

consulting the monitoring of the kibana, the jvm heapsize of the elastic is always close to **38gb** , with a good margin up to the 48gb available.

I need a light, thanks for any tips.

---

<div class="post-metadata">

**Author:** ![angelogabeira](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@angelogabeira](https://discuss.elastic.co/u/angelogabeira)\
**Post date:** [July 2, 2021, 2:32pm UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/2 "2021-07-02T14:32:09Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/1/7/17e15791a1687fa3632d43536b1607e199221c30.png)

---

<div class="post-metadata">

**Author:** ![angelogabeira](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@angelogabeira](https://discuss.elastic.co/u/angelogabeira)\
**Post date:** [July 2, 2021, 2:35pm UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/3 "2021-07-02T14:35:29Z")

</div>

![image](https://us1.discourse-cdn.com/elastic/original/3X/3/4/3439bc92a3849b885eb38dae9d6a9d3e4dcbcc3a.png)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 3, 2021, 2:45pm UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/4 "2021-07-03T14:45:11Z")

</div>

> [@angelogabeira](#):
>
> server has 64gb of ram and elastic heapsize is 48gb.

This sounds like a problem. The recommendation is to keep the Java heap at 50% of the available host RAM (assuming no other processes running there) and at a maximum of around 30GB. This allows Java to use compressed pointers which is more efficient. As soon as you go over this level you stop benefitting from this and the usable heap space goes actually goes down. I would recommend reading [this blog post](https://www.elastic.co/blog/a-heap-of-trouble) and [this part of the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/6.8/heap-size.html) for further details.

---

<div class="post-metadata">

**Author:** ![angelogabeira](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@angelogabeira](https://discuss.elastic.co/u/angelogabeira)\
**Post date:** [July 5, 2021, 11:47am UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/5 "2021-07-05T11:47:10Z")

</div>

I had already tried to follow this recommendation in the past but I was unsuccessful, after your tip I tried again to use the 32gb heap and continued with the error below in the GC log, this happens practically every second.  
any more suggestions?  
thanks for your time.

- age 1: 66388528 bytes, 66388528 total  
: 971343K-\>89885K(996800K), 0.0505691 secs] 17053661K-\>16227764K(33443712K), 0.0507470 secs] [Times: user=0.48 sys=0.01, real=0.05 secs]  
2021-07-05T08:44:57.524-0300: 392.346: Total time for which application threads were stopped: 0.0523419 seconds, Stopping threads took: 0.0007045 seconds  
2021-07-05T08:44:57.767-0300: 392.589: [GC (Allocation Failure) 2021-07-05T08:44:57.767-0300: 392.589: [ParNew  
Desired survivor size 56688640 bytes, new threshold 6 (max 6)

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 5, 2021, 11:55am UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/6 "2021-07-05T11:55:43Z")

</div>

The limit is below 32GB, not exactly 32GB. I think the blog post I linked to describes how to identify you are bolow the cutoff point.

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [July 5, 2021, 11:58am UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/7 "2021-07-05T11:58:02Z")

</div>

What Java version?

How many CPUs? Any thread pool tuning?

ES: how many nodes / indices / shards / documents?

Most the time, GC error is because a wrong architecture, or too much traffic.

---

<div class="post-metadata">

**Author:** ![angelogabeira](https://avatars.discourse-cdn.com/v4/letter/a/ec9cab/32.png) [@angelogabeira](https://discuss.elastic.co/u/angelogabeira)\
**Post date:** [July 5, 2021, 12:22pm UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/8 "2021-07-05T12:22:47Z")

</div>

What Java version?  
java version "1.8.0\_191"

How many CPUs?  
CPU(s): 16, CPU MHz: 2394.000  
Any thread pool tuning?  
this I don't know what it is and how to see

ES: how many nodes / indices / shards / documents?  
1 node, 282 Indices, 664 Shards, 32.6m Documents

---

<div class="post-metadata">

**Author:** ![ebuildy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ebuildy/32/6070_2.png) [@ebuildy](https://discuss.elastic.co/u/ebuildy)\
**Post date:** [July 5, 2021, 3:17pm UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/9 "2021-07-05T15:17:02Z")

</div>

1. upgrade java version if possible ([Elastic Support Matrix | Elasticsearch](https://www.elastic.co/fr/support/matrix#matrix_jvm))
2. 1 node with replica ? if yes, disable replicas
3. too many shards for 32m document, what the index size ?
4. I am sure a single index with 8 shards could be better

---

<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:** [August 2, 2021, 3:17pm UTC](https://discuss.elastic.co/t/main-problem-with-garbage-collector/277656/10 "2021-08-02T15:17:55Z")

</div>

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