# Why is my heap usage always high?

**URL:** <https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017>\
**Category:** Elasticsearch\
**Created:** [March 21, 2016, 4:15pm UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017 "2016-03-21T16:15:21Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![trevan](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@trevan](https://discuss.elastic.co/u/trevan)\
**Post date:** [March 21, 2016, 4:15pm UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/1 "2016-03-21T16:15:21Z")

</div>

I have a cluster with 8 nodes and all the nodes almost always show a heap usage in the high 70%. I never seem to see a "pretty jigsaw" pattern in the heap usage.

All the nodes are in individual systems that have 64GB of RAM. The nodes are given 24GB of RAM. So they should have plenty of space.

I've looked at fielddata size and it is almost always less than 1GB. I've cleared it several times (through both restarting the node and running the clear cache command).

We have 2446 indices (we have several indices that are daily rollovers and have data back for almost 1 year). Most of the indices have 4 shards plus a backup. The total number of shards is 17745.

Is heap usage supposed to be always high? How do I find out what is using heap usage?

---

<div class="post-metadata">

**Author:** ![trevan](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@trevan](https://discuss.elastic.co/u/trevan)\
**Post date:** [March 21, 2016, 4:24pm UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/2 "2016-03-21T16:24:45Z")

</div>

Oh, we are also running ES 1.7.3

---

<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:** [March 21, 2016, 9:03pm UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/3 "2016-03-21T21:03:56Z")

</div>

> [@trevan](#):
>
> The total number of shards is 17745

That's too much! You are probably wasting a lot of resources with that alone.

---

<div class="post-metadata">

**Author:** ![trevan](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@trevan](https://discuss.elastic.co/u/trevan)\
**Post date:** [March 22, 2016, 1:42am UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/4 "2016-03-22T01:42:18Z")

</div>

Is 4 shards plus 4 backup shards per index too much?

---

<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:** [March 22, 2016, 2:26am UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/5 "2016-03-22T02:26:07Z")

</div>

How much data in the cluster?

---

<div class="post-metadata">

**Author:** ![trevan](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@trevan](https://discuss.elastic.co/u/trevan)\
**Post date:** [March 22, 2016, 4:31am UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/6 "2016-03-22T04:31:51Z")

</div>

Cluster stats says indices.store.size = 15.8T and it has 5.6 billion docs

---

<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:** [March 22, 2016, 4:36am UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/7 "2016-03-22T04:36:11Z")

</div>

Yeah, so about 8 GB per shard, way too small.

Aim for \<50GB per shard by reducing the shard count, or use weekly/monthly indices instead to increase the data in each shard.

---

<div class="post-metadata">

**Author:** ![trevan](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@trevan](https://discuss.elastic.co/u/trevan)\
**Post date:** [March 22, 2016, 5:08am UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/8 "2016-03-22T05:08:44Z")

</div>

Ok, I'll try that out. Thanks

---

<div class="post-metadata">

**Author:** ![trevan](https://avatars.discourse-cdn.com/v4/letter/t/7feea3/32.png) [@trevan](https://discuss.elastic.co/u/trevan)\
**Post date:** [February 3, 2017, 9:33pm UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/9 "2017-02-03T21:33:57Z")

</div>

Mark,

We are still dealing with high heap usage. We've changed how we rollover our indices to now be size based. The total number of shards is now 5365 and the total size is 160T. That comes to about 30G per shard.

On one of the nodes, there are 318 shards. The doc count is 4.2B and the size on disk is 9.5T. The heap usage is 80% (27.4G). Query cache memory is 350M, fielddata memory is 350M, and segments memory is 14G (terms is 10.1G, stored\_fields is 2.4G, norms is 1M, and doc\_values is 1.5G). This particular node will climb from 75% heap usage to 80% heap usage in 3 minutes and then repeat.

Any ideas on how to decrease the ram usage without adding more ES instances?

---

<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:** [February 3, 2017, 9:59pm UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/10 "2017-02-03T21:59:39Z")

</div>

At this stage you will just need to add more nodes.

---

<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:** [July 5, 2017, 10:03pm UTC](https://discuss.elastic.co/t/why-is-my-heap-usage-always-high/45017/11 "2017-07-05T22:03:34Z")

</div>


