Setting JVM Heap size for Elasticsearch container

I recently ran into an error where my cluster would turn red due to exceeding the maximum allocated heap. Once it returned back to below the threshold, I saw that by default, only 512mb was allocated.

name id   node.role   heap.current heap.percent heap.max
es01 yzkn cdfhilmrstw      400.7mb           78    512mb

Checking my docker stats, I see:

CONTAINER           CPU %               MEM USAGE / LIMIT   MEM %               NET I/O             BLOCK I/O          
kibana              0.61%               504 MiB / 1 GiB     49.22%              2.83 GB / 3.9 GB    0 B / 0 B          
elasticsearch       0.04%               998.1 MiB / 1 GiB   97.47%              580 MB / 234 MB     10.4 GB / 1.18 GB 

I plan on bind mounting my own jvm.options file to /usr/share/Elasticsearch/config/jvm.options.d/ (- ./elasticsearch/config/jvm.options:/usr/share/elasticsearch/config/jvm.options.d/jvm.options in my docker-compose file), but had a quick question on configuring this file.

As of now, my server has 32 GB of RAM, and I saw that the recommended amount is half of your total RAM. I plan to have the following settings in my jvm.options file:

-Xms16g
-Xmx16g

Would this maximize the memory usage on my Elasticsearch container? Are there any other suggested configuration changes?

The getting started documentation also contains a paragraph about setting the heap size. See Running the Elastic Stack ("ELK") on Docker | Getting Started [8.1] | Elastic

1 Like

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