Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add a recommended PHP memory_limit value for just running Magento 2 in production #739

Closed
hostep opened this issue Jul 3, 2016 · 14 comments
Assignees

Comments

@hostep
Copy link
Contributor

hostep commented Jul 3, 2016

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!

@ghost ghost self-assigned this Jul 4, 2016
@ghost
Copy link

ghost commented Jul 4, 2016

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.

@hostep
Copy link
Contributor Author

hostep commented Jul 4, 2016

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 :)

@ghost ghost added the Waiting for Response Waiting for response from internal/external parties label Oct 23, 2016
@ghost
Copy link

ghost commented Oct 26, 2016

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.

@scottsb
Copy link
Member

scottsb commented Jan 11, 2017

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

@ghost
Copy link

ghost commented Jan 11, 2017

Good catch, thanks! I updated documentation.

@hostep
Copy link
Contributor Author

hostep commented Jan 11, 2017

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).

@tanberry
Copy link

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

@ghost
Copy link

ghost commented Jan 11, 2017

@hostep How do you update Magento and components?

@hostep
Copy link
Contributor Author

hostep commented Jan 11, 2017

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)

@ghost
Copy link

ghost commented Jan 11, 2017

@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?

@scottsb
Copy link
Member

scottsb commented Jan 11, 2017

@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

@ghost
Copy link

ghost commented Jan 11, 2017

@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

magento-cicd2 pushed a commit that referenced this issue Mar 15, 2017
Remove order tutorial for now, it’s not ready
@jcalcaben jcalcaben self-assigned this May 11, 2017
@jcalcaben
Copy link
Contributor

Closing due to lack of activity.

@hostep
Copy link
Contributor Author

hostep commented Aug 24, 2017

@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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants