Elasticsearch is pretty much garbage in my opinion, yet it is a requirement for Magento. It constantly consumes over 50% of my RAM on my EC2 ubuntu instance. Every week or so, my website goes down because it can't be reindexed due to the Elasticsearch service being stopped. I know I'm not the only one dealing with this issue. I'm sure it is because the service is being killl by an OOM killer. I've already bumped my EC2 instance to 8GB. I refused to bump it any higher. A website should not be consuming this much ram, it is absolutely insane.
Can someone explain to me how to reduce the memory footprint of Elasticsearch and/or explain to my why it is randomly crashing?
The bottleneck behind the poor performance on EC2 instances might be due to CPU throttling. When the CPU is getting exhausted due to the fact that is working above the baseline performance is using the accumulated credits (depending on the instance type) if your credits are finished your instance is kept to performing at baseline performance so the CPU cannot go above that baseline anymore.
All these being said I do not recommend having ES and MySQL on the webserver. Each service needs different configurations depending on what they're used for. You just cannot install ES on your instance and done. If you do so, you gonna use it with the default configurations and you gonna have to manually configure and adapt them to your use case.
A well-designed and structured infrastructure adapted to your needs it can help you to spend less money and scale up and down whenever is necessary for how long is necessary.
- Edit JVM heap size:
- Open file /etc/elasticsearch/jvm.options
- Uncomment -Xms1g, -Xmx1g
- Restart elastic search