Elastic search is occupying more than 25 GBs of RAM. Data that I gave for indexing to elastic search is around 1 GB. Why elastic search needs this much of space?
Whenever an Elastic Search starts with default settings it consumes about 1 GB RAM because of their heap space allocation defaults to 1GB setting.
Make sure to check the "jvm.options" File
For Ubuntu Linux OS :- {if installed using debian File} File Location :- /etc/elasticsearch/
or
For Windows OS :- File Location is the extracted folder Location {extacted_folder_path/config/jvm.options}
Inside jvm.options file you need to configure some settings of JVM Heap
-Xms1g
-Xmx1g
-Xms1g is set to acquire 1 GB of initial RAM size whenever elastic search starts. -Xmx1g defines the maximum allocation of RAM to Elastic Search JVM Heap.
You need to tune these two parameters to 4 GB or whatever suits your needs.
-Xms4g
-Xmx4g
Note :- Do not set more than 32 GB Java Heap Space it will not lead to any benefit.
From some reason "elasticsearch" used 53% of my 24G memory by default which is insane if you ask me. Maybe because it is auto configured as it stated in the text below. Anyway, to set custom JVM heap size, one should create a file "jvm.options" in jvm.options.d
directory and add custom values as stated in default "jvm.options" file:
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## The heap size is automatically configured by Elasticsearch
## based on the available memory in your system and the roles
## each node is configured to fulfill. If specifying heap is
## required, it should be done through a file in jvm.options.d,
## and the min and max should be set to the same value. For
## example, to set the heap to 4 GB, create a new file in the
## jvm.options.d directory containing these lines:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
I've set the memory usage to 1G, so the file look like this:
-Xms1g
-Xmx1g
Then you should restart "elasticsearch" service and you can check the memory usage with:sudo service elasticsearch status
Elasticsearch and jvm versons:
Version: 7.11.0, Build: default/deb/8ced7813d6f16d2ef30792e2fcde3e755795ee04/2021-02-08T22:44:01.320463Z, JVM: 15.0.1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With