<p>So i have a Elasticsearch Cluster inside the Kubernetes.</p>
<p>The machine it is running on has 30 GB RAM and 8 cores.</p>
<p>Now according to the thumb rule 50% of the RAM is what we set as <code>ES_JAVA_OPTS</code> and remaining is used for file caching.
here it would be 15 GB</p>
<p>Also in the helm chart we have resource requirements mentioned like below:</p>
<pre><code>resources:
  limits:
    cpu: 8
    memory: 15Gi
  requests:
    cpu: 8
    memory: 15Gi
</code></pre>
<p>My question is whether the 50% RAM is of the host machine (Which is 30 GB) or the limit specified in the helm chart 15 GB</p>
<p>Can someone explain how in kubernetes utilise the RAM</p>
<p>Because if it with respect to Host and file caching is not considered as the utilisation of Deployed Application we are OK. But if it within the Resources Limits i need to increase the to 30GB.</p>
<p><strong>Edit:</strong></p>
<p>The question here is that if one elasticsearch node used 50% of RAM as Heap and 50% as file caching and i mention the Heap as 15GB (50% of the RAM) in a 30GB machine. so should i mention the resoure limitations in the deployment template as somewhere around 15GB which Heap requires of need 30GB (Say 28GB) that from the rule Elasticsearch need to be able to cache files.</p>
<p>This comes as concern as if pod exceed the mentioned limit on the template at any given moment kubernetes restart the pod.</p>
<p>So in other words i want to know the RAM file caching is come into play in the overall memory usage of the pod or not.</p>
<p>Note: I am using instance storage as primary Storage of the ES Data as this is extremely fast as compare to EBS.</p>
<p><strong>Conclusion</strong>:</p>
<p>Keep Heap half to the RAM in the system and Mentioned in the resources Limit(if any)</p>

<p>I am not a expert in k8s and docker but what I understand is that, docker container uses the host resources and using resource limit you can have a hard limit on the resources it can consume.</p>
<p>If you put a resource limit of 15GB, than overall your docker container can consume 15GB of host RAM.now whether it will share the file system cache with host or not depends on how you have configured your docker volume.</p>
<p>As docker container have the option to share the file system with host using the <a href="https://docs.docker.com/storage/bind-mounts/" rel="nofollow noreferrer">bind volume</a> or have its own data volume(which is ephemeral and not suited for ES as its a stateful application). in first option it should share the file system cache with host and you should not increase the resource limit further(recommended as you have ES which is stateful) and in second option, as it will use its own file system you have to allocate RAM for its file system cache and have to increase RAM to 30 GB, but you have to give some space for Host OS as well.</p>
