Elasticsearch installation follow up

Hi Craig,

Thank you for your time in doing the Elasticsearch tutorial. It is very helpful. I installed it with no pain :slight_smile:

However, after I installed it my memory usage jumped from 20% to 55% and I can’t install/update any modules via CLI.

The following message is shown.

“mmap() failed: [12] Cannot allocate memory”

My environment: Ubuntu 16:04, DigitalOcean 4GB, php_value memory_limit 2G for mod_php7.c

It looks like elastic search is very hungry for memory or I config something wrongly.
I want to use ES so I have to change the hosting plan in order to use it or is there a different way?

Can you give me a tip?
Thank you.
Pawel

Yes, I have the same problem - Which is why I made that note at near the beginning of the post about having to increase my server specs. This really makes sense as my Dev Server was only running 2GB and I had already bolted on things like Redis and Elasticsearch.

Bare in mind, your .htaccess file only controls the directory environment (e.g. anything running in the Magento folder).

Elasticsearch will be tapping into your system variables (not your Magento directory variables). Therefore, try increasing your memory_limit to 3-4GB in your main php.ini file. Don’t forget to to restart apache when changing php.ini.

1 Like

Hi,

I config swap-file following your instruction from one of your responses posts.

It worked.

1 Like

Hi Craig,

with regards to modifying php.ini file.

Should I replace the -1 to 3 or 4G.

Maybe it is a stupid question but why by default there is -1 value?

Using memory_limit = -1 is bad practice. But often ends up being a “sticky-plaster” solution for most. The problem with having no cap is that you have no real control of applications hogging system resources.

The actual default value of memory_limit is 128M. So, I have no idea why yours is set to this.

If I recall correctly, on my Sandbox/Development servers I have this set to 2G (out of 4 total). This is because those servers aren’t high-spec. On a Dedicated Production Server with 16-32G available, I still won’t increase this limit to more than 4G (unless there are clear signs of bottlenecking).

I guess it depends on what other applications you have that eat memory other than PHP… Like JDK or Redis for example.

When I originally started making Magento 2 videos way-back-when, the basic 2G Web Servers were fine. Now as Magento 2 evolves and relies on more applications, I’m starting to find the basic requirements starting to go up.

In my Install Magento 2.4 video, I’ll likely recommend a min of 4G instead of 2G (because it will have to include Elasticsearch). I think that’ll upset those who are concerned about running costs, but I’d rather be realistic and set real expectations.

References

1 Like

Well recommendation for Elastic search is to have at least 3 severs (minimum) if you are going to use it for production. But a single server is good for development/testing.

Also whats your swap? A minimum of 4 GB RAM is required for Magento to work smoothly along with PHP/web server. However, if you also have other services on same server such as this Elastic search, you might end up slowing down your server once your RAM is used, and not to forget swap is slow as compared to RAM. Also it depends on the no. of cores.

I will recommend you to create a new droplet for Elastic search and/or Redis. Also as @digitalstartup already mentioned, -1 is not good, change it to 2 or 3 G.

1 Like

Hey Craig hope you doing good…!

I have installed elasticsearch-7.6.0 successfully but I couldn’t find Elasticsearch 7 on my configuration page, is there any other way to install manually?

  • Magento v2.3.4

Looks like Elasticsearch 7.0+ support was added in Magento 2.3.5. I’ve just updated the main article to reflect this, as I didn’t realise at the time. Sorry about that.

1 Like

oh okay i;m such a stupid :sweat_smile:

is it possible to install Elastic Search 7 alone? instead of v 2.3.5 update.

Not to my knowledge. But to be fair, you should really be on 2.3.5. You’re missing out on over 180 functional fixes to the core product and over 25 security enhancements. And includes resolution of over 46 GitHub issues by our community members.

There are 2 php.ini files, one has memory_limit = 128M by default, the other has the -1 that you are seeing…

/etc/php/7.4/apache2/php.ini (memory_limit = 128M by default)
/etc/php/7.4/cli/php.ini (memory_limit = -1 by default)
1 Like