# Heap size when running elasticsearch on kubernetes

**URL:** <https://discuss.elastic.co/t/heap-size-when-running-elasticsearch-on-kubernetes/214502>\
**Category:** Elasticsearch\
**Created:** [January 9, 2020, 10:14pm UTC](https://discuss.elastic.co/t/heap-size-when-running-elasticsearch-on-kubernetes/214502 "2020-01-09T22:14:12Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ntsh999](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ntsh999/32/51172_2.png) [@ntsh999](https://discuss.elastic.co/u/ntsh999)\
**Post date:** [January 9, 2020, 10:14pm UTC](https://discuss.elastic.co/t/heap-size-when-running-elasticsearch-on-kubernetes/214502/1 "2020-01-09T22:14:12Z")

</div>

I am running elasticsearch cluster on Kubernetes cluster. I have a need to increase the heap size. Right now the heap size is 4gb and memory allocated to the pod is 8gb. When setting up elastic search cluster on VMs/BMs I have always followed the principle that heap size should not be more than 50% of physical RAM. Please follow link [https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html) Now my question is, will this principle work in the same manner when running elastic search on K8 or how to decide the heap size when running ES on K8?

---

<div class="post-metadata">

**Author:** ![DavidTurner](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidturner/32/22453_2.png) [@DavidTurner](https://discuss.elastic.co/u/DavidTurner)\
**Post date:** [January 10, 2020, 11:49am UTC](https://discuss.elastic.co/t/heap-size-when-running-elasticsearch-on-kubernetes/214502/2 "2020-01-10T11:49:01Z")

</div>

Yep, the same principle applies. If you have allocated 8GB of memory to a pod then Elasticsearch must have a heap size no greater than 4GB. From the link you shared:

> Elasticsearch requires memory for purposes other than the JVM heap and it is important to leave space for this. For instance, Elasticsearch uses off-heap buffers for efficient network communication, relies on the operating system’s filesystem cache for efficient access to files, and the JVM itself requires some memory too.

---

<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:** [February 7, 2020, 11:49am UTC](https://discuss.elastic.co/t/heap-size-when-running-elasticsearch-on-kubernetes/214502/3 "2020-02-07T11:49:12Z")

</div>

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