# Why the JVM heap of ES is always about 50%?

**URL:** <https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755>\
**Category:** Elasticsearch\
**Created:** [July 27, 2017, 8:34am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755 "2017-07-27T08:34:49Z")\
**Posts on this page:** 18\
**Page:** 1

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [July 27, 2017, 8:34am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/1 "2017-07-27T08:34:49Z")

</div>

ES version: 5.5.1

Is this a coincidence or something else?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 27, 2017, 9:23am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/2 "2017-07-27T09:23:27Z")

</div>

Because we leverage the OSs ability to cache commonly accessed files in the remainder of the memory.

---

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [July 27, 2017, 9:37am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/3 "2017-07-27T09:37:36Z")

</div>

So... how do I decide the heap size of ES? 2gb by default is ok?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [July 27, 2017, 10:15am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/4 "2017-07-27T10:15:20Z")

</div>

That's a massive - it depends.

What sort of data, how much, what sort of queries, what version, what JVM, what SLAs do you have?

---

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [July 27, 2017, 10:40am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/5 "2017-07-27T10:40:31Z")

</div>

The data is nginx access log, about 100gb every day, java is open-jdk-1.8.0.

I use ELK to collect and analysis nginx logs, how to get the info you mentioned above...?

---

<div class="post-metadata">

**Author:** ![Spacefish](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spacefish/32/20675_2.png) [@Spacefish](https://discuss.elastic.co/u/Spacefish)\
**Post date:** [August 1, 2017, 11:58am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/6 "2017-08-01T11:58:58Z")

</div>

We generally use 3/4 of the physically available RAM as the JVM HeapSize for Elasticsearch..  
More RAM = Better as Lucene can keep more segments in RAM.

But depends on the queries.. If you create indeces per day and only access the last few days you wan´t need as much RAM as if you access all the data all the time.. Ideally you want to be able to keep all interactively browsed data in memory.

As much as i love Free Software, don´t use open-jdk it´s much slower than the properitary OracleJVM..

---

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [August 2, 2017, 2:35am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/7 "2017-08-02T02:35:38Z")

</div>

> [@Spacefish](#):
>
> don´t use open-jdk it´s much slower than the properitary OracleJVM…

Really?😳

It's very slow when I view the dashboard in 7 days...

---

<div class="post-metadata">

**Author:** ![theuntergeek](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/theuntergeek/32/44961_2.png) [@theuntergeek](https://discuss.elastic.co/u/theuntergeek)\
**Post date:** [August 2, 2017, 2:53pm UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/8 "2017-08-02T14:53:41Z")

</div>

The out of the box settings for Elasticsearch do not have the JVM triggering a garbage collection until the heap reaches 70%. The goal for most users of Elasticsearch should be to keep the heap at or near 50% _after_ a GC has completed. If the heap is near, or above 70% on a regular or continual basis (or cannot clean up RAM after a GC so it stays around 70%), that's evidence of memory pressure, which indicates a need for more heap, or more nodes, or perhaps both.

---

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [August 3, 2017, 3:22am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/9 "2017-08-03T03:22:01Z")

</div>

Great!!! Thanks a lot for your explanation, remove many my doubts! 😀

---

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [August 3, 2017, 4:23am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/10 "2017-08-03T04:23:05Z")

</div>

@warkolm@Spacefish @theuntergeek

By the way, what about the heap size of logstash?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 3, 2017, 4:24am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/11 "2017-08-03T04:24:19Z")

</div>

What about it exactly would you like to know?

---

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [August 3, 2017, 4:26am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/12 "2017-08-03T04:26:40Z")

</div>

Maybe it should be percent of physical memory?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [August 3, 2017, 4:34am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/13 "2017-08-03T04:34:35Z")

</div>

Not really, it only needs to hold a small amount of data in memory, so unless you have very large events, a few GB should be sufficient.

---

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [August 3, 2017, 4:39am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/14 "2017-08-03T04:39:12Z")

</div>

How to check the size of events?

---

<div class="post-metadata">

**Author:** ![Ravi\_Shanker\_Reddy](https://avatars.discourse-cdn.com/v4/letter/r/a5b964/32.png) [@Ravi\_Shanker\_Reddy](https://discuss.elastic.co/u/Ravi_Shanker_Reddy)\
**Post date:** [August 3, 2017, 4:51am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/15 "2017-08-03T04:51:10Z")

</div>

Depends on so many cases.

**A Basic one:** A single line in your log file is an event. The size of the line becomes the size of the event.

It varies if you are creating new variables, or using multi line and so many other ways

---

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [August 7, 2017, 7:59am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/16 "2017-08-07T07:59:09Z")

</div>

Thanks, I found `Events Received` and `Events Emitted` on monitoring of kibana...

---

<div class="post-metadata">

**Author:** ![KeithTt](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/keithtt/32/29447_2.png) [@KeithTt](https://discuss.elastic.co/u/KeithTt)\
**Post date:** [August 7, 2017, 8:02am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/17 "2017-08-07T08:02:01Z")

</div>

Replace openjdk by oracleJDK, load average decrease much, amazing...Thanks a lot!!!😘

---

<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:** [September 4, 2017, 8:02am UTC](https://discuss.elastic.co/t/why-the-jvm-heap-of-es-is-always-about-50/94755/18 "2017-09-04T08:02:06Z")

</div>

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