Hello everyone, good evening. I'm experiencing seemingly high memory consumption from Elasticsearch and would like to know if anyone else has experienced this and how they optimized.
Scenario:
Elasticsearch started, no heavy usage, already consumes ~54.9% of RAM.
Machine configuration:
RAM: 16GB
Processor: Intel Core i7-1255U (12th Generation)
Disk: SSD 512GB
OS: Ubuntu 20.04.6 LTS (64-bit)
Questions:
Is this consumption (~8-9GB) normal for Elasticsearch just being on?
Are there any recommended settings to optimize RAM usage?
Has anyone faced this and managed to reduce consumption without compromising performance?
Any tips would be appreciated!
Assuming you are using a recent release of Elasticsearch it by default assigns 50% of available RAM to the heap. It is recommended that Elasticsearch run on dedicated hardware, but if that is not the case for you, you may need to specificially set the heap size in the jvm.options
file. Note that Elasticsearch also makes use of off-heap memory and it is recommended to set the heap size to 50% of the amount of memory you can dedicate to Elasticsearch.
Yes, with default settings on a host with 16GB RAM it is.
If Elasticsearch is the only servoce running on the host (recommended best practice) this default setting should be fine. If not, you need to manually set the heap size as I described above.
Hi, Christian. The jvm.options file didn't have the heap size (-Xms and -Xmx) explicitly set, so Elasticsearch was probably automatically adjusting the RAM usage.
As the file itself recommends, it shouldn't be edited directly, so I created a new file inside the jvm.options.d directory to set a fixed memory limit, at first: -Xms4g
-Xmx4g. Now, I'll observe the performance.
Thanks for your help!
That's fine. If the performance is fine for you, then your settings are similarly fine and the thread is done.
Note, unless you tweaked things in the kernel or elsewhere, any RAM that elasticsearch doesn't directly use itself is still indirectly used (and helpful) via the file system cache(s). This can be monitored by 101 different linux tools.