Search code examples
elasticsearchkubernetesresourceskubernetes-helm

What is the relationship between Elasticsearh ES_Java_Opts and Kubernetes Resource Limits


So i have a Elasticsearch Cluster inside the Kubernetes.

The machine it is running on has 30 GB RAM and 8 cores.

Now according to the thumb rule 50% of the RAM is what we set as ES_JAVA_OPTS and remaining is used for file caching. here it would be 15 GB

Also in the helm chart we have resource requirements mentioned like below:

resources:
  limits:
    cpu: 8
    memory: 15Gi
  requests:
    cpu: 8
    memory: 15Gi

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

Can someone explain how in kubernetes utilise the RAM

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.

Edit:

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.

This comes as concern as if pod exceed the mentioned limit on the template at any given moment kubernetes restart the pod.

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.

Note: I am using instance storage as primary Storage of the ES Data as this is extremely fast as compare to EBS.

Conclusion:

Keep Heap half to the RAM in the system and Mentioned in the resources Limit(if any)


Solution

  • 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.

    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.

    As docker container have the option to share the file system with host using the bind volume 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.