Devdocs: Add a recommended PHP memory_limit value for just running Magento 2 in production

Created on 3 Jul 2016  路  14Comments  路  Source: magento/devdocs

Hi

I noticed you added a bunch of recommended memory_limit values over here and here:

Our detailed recommendations are:

  • Compiling code, 768M
  • Deploying static asses, 768M
  • Installing and updating Magento components from Magento Marketplace, 1G
  • Testing, 2G

But there is one crucial recommendation missing: namely what memory_limit do we need to use to just run Magento 2's frontend and backend.
I believe you currently recommend 768M, but I can't believe that's actually true, that's just way too high.
We currently run our M2 shops with memory_limit set to 512M, but it wouldn't surprise me one bit if this can still be reduced a lot.

Would be great if Magento can give us some official recommendations about this.

Thanks!

Most helpful comment

@jcalcaben: I was hoping the devdocs team would ask this to the dev team for a clear answer, but if there isn't one, then ok, too bad :(
I still believe the recommended memory_limit is way too high for smaller webshops. But even bigger ones, we have a Magento 2.1.7 project with 98000 products running with a memory_limit of 256M with no memory issues at the moment.

All 14 comments

In my personal opinion, Magento should not recommend these settings because they're too dependent on what you want to do. Import/export and testing drives memory usage way up and memory is pretty cheap isn't it?

I'll ask for advice and update you.

You have a point there, although for testing you already recommend a value (2G).
My question was for a production environment (testing shouldn't be performed on a production environment).
Import/export is something you (normally) do using a cronjob, so this runs in the background using php-cli which has no memory limit by default.

I'm looking for a value for just running a vanilla Magento 2 instance without any extra modules and a small catalogue of products.

But you are right, it will probably depend from store to store and how big the catalogue is and what features get used and what external modules are installed, ...

But just a bare minimum recommendation would be helpful.

I think a year ago, I tested a Magento pre-2.0.0 version on a server running PHP 5.5, with the configuration set to 192M and if I remember correctly it was running just fine, so the recommended value of 768M in the .htaccess file for example is slightly exaggerated :)

This and issue #419 are expected to be resolved with the 2.2 release but I don't know a time frame for that release.

For what it's worth, the Magento setup code itself looks for a minimum memory level of 756MB, not 768MB. Those few MB are unlikely to be significant, but it's an odd discrepancy.

https://github.com/magento/magento2/blob/develop/setup/src/Magento/Setup/Model/PhpReadinessCheck.php#L190

Good catch, thanks! I updated documentation.

I still believe this limit is ridiculously high.
We are currently running a Magento CE 2.1.2 in production on an environment using PHP 7.0.14 where memory_limit is set to 192M and it is running without any problems (for webserver requests that is, for php-cli the setting is set to -1).

@misha-kotov can you please read above, particularly @hosteps post on July 4th, re: test versus prod environs?

@hostep How do you update Magento and components?

Using composer on our local machines (which uses php-cli and a memory_limit of -1), and then deploying the changes to the production server.
We never update Magento or modules directly on the production server, that's just a very very very very very bad idea.
(I realize that non-technically skilled people probably do it this way, and I don't think Magento 2 is meant for non-technically skilled people, but that's just my opinion)

@hostep Thanks. I am a bit dense about this. Does -1 "just work"? IOW, if you're not using a memory-strapped machine, is that the best way to manage PHP memory?

@xcomSteveJohnson, -1 would "just work" since it allows PHP to use unlimited memory. However, it would be a very bad idea in production, as it could allow a memory leak in one runaway process to crash or lock up the entire server. In a development environment, the minimal risk may be worth the simplicity, as @hostep implies.

Separately, I just noted that the Magento code (in the next line after I linked above), specifies 2GB as the minimum for running the Magento setup wizard. This is not precisely the same as component/module updates, but it yet another data point to consider for the docs:
https://github.com/magento/magento2/blob/develop/setup/src/Magento/Setup/Model/PhpReadinessCheck.php#L191

@hostep @scottsb We cover it here: http://devdocs.magento.com/guides/v2.1/install-gde/prereq/php-settings.html:

Installing and updating Magento components from Magento Marketplace, 2G

Closing due to lack of activity.

@jcalcaben: I was hoping the devdocs team would ask this to the dev team for a clear answer, but if there isn't one, then ok, too bad :(
I still believe the recommended memory_limit is way too high for smaller webshops. But even bigger ones, we have a Magento 2.1.7 project with 98000 products running with a memory_limit of 256M with no memory issues at the moment.

Was this page helpful?
0 / 5 - 0 ratings