It’s a common issue with Magento 2 , after a while Elasticsearch will crashed if it could not find enuaf RAM.
Why this should happen? when ES started it try to use all RAM to save it data. all thing will be okay but when Apache or PHP needs to more RAM based on their processed they can not find memory because that Elasticsearch will crashed.
How we can set limit on Elasticsearch prepossess. it’s easy just follow this setup:
Contents
hide
1- open /etc/elasticsearch/jvm.options
by nano or vim
2- check -Xms4g
and -Xmx4g
are commented or not.
3 : please comment them.
4: Create new file on this directory : nano /etc/elasticsearch/jvm.options.d/heat.options
the file name is optional but extension .options
is essential
5: put below line and save file
-Xms1g
-Xmx4g
Xms1g : show we set minmum RAM to 1 Gig
Xmx1g : show we put maxmum RAM to 4 Gig
after thos setup you need to restart Elasticsearch :
sudo service elasticsearch restart
reference : elastic.co/guide/en/elasticsearch/reference/7.16/advanced-configuration.html#set-jvm-heap-size