16

What are the system requirements of Magento 2 regarding PHP memory limit (Resource Limits: memory_limit)?

I have problems to find these informations in the System Requirements despite the second release candidate has been already pushed out.

1
  • When a system with 2048M for memory_limit was reviewed, the comment from reviewers were "For vanilla Magento 1024M recommended". This is ca. Mid Oct 2015.
    – hakre
    Dec 3, 2015 at 15:25

3 Answers 3

14

The official system requirements (or rather: recommendations) are:

Increase the PHP memory limit to at least 768MB for normal operation or 2GB for testing.

Source: Recommendations for CentOS and Ubuntu

I would only increase it to a higher value if you encounter problems where the memory limit is hit. Then debug and fix these problems, and set the memory limit back to normal when successful.

4
  • My cron job doesn't work even I put memory limit to 768 MB Nov 2, 2016 at 13:47
  • 2
    So? What kind of answer do you expect to this? Nov 2, 2016 at 14:16
  • 1
    I don't expect an answer on it, I just informed that cron doesn't run even with 768M. That's it. It may be useful for other people who read this page. Nov 2, 2016 at 14:40
  • OK, sorry for the misunderstanding. But of course this depends on what the cron is doing. There might be extensions involved that need optimization. Nov 2, 2016 at 15:10
3

Actually memory_limit is totally up to you, you have to see how your application behaves. Do not be confused with big numbers. Any script must work as fast as possible and take not much than 3-4 times of its per process memory, which is 60MB x 4 = ~300MB an average. IMHO

768mb is just a precaution, so your server will not melt down or become unresponsive.

In some circumstances it may go beyond, so you have to debug these cases. configure your database and web stack.

4
  • PHP memory limit is configured per process. Also a lot of your answer sounds like speculation. And the first sentence is right only to the case that it's me who can configure it, but it's not up to me regardless the case that with let's say the configuration default of 128M Magento will refuse to work. Have you verified the concrete number 768M you give in the answer that it is working? On which specification is your calculation based, can you please reference it with a hyperlink and quote the underlying parts from it? How does it add to the given answer?
    – hakre
    Nov 16, 2015 at 8:29
  • you just dont understand - it will work with default value, you can even set -1 it is simply depends on your magento code and stack configuration. you must yourself come to this, to find the right limit.
    – MagenX
    Nov 16, 2015 at 8:49
  • I beg your pardon, but I have not asked about how to configure or change the PHP memory limit. I'm perfectly aware of it and how it works. I'm asking about what the vendor of the Magento Commerce Version 2 software specifies as a memory limit. If you set to -1 for example but the system you've got Magento 2 running on for example has only 128 MB that system would certainly not match the system requirements. Even though you set PHP memory limit to -1. The point in question here is the asking for reference. In your answer you don't give Magento 2 specific reference.
    – hakre
    Nov 16, 2015 at 9:04
  • i gave you the explanation, this value is not constant or given exact up to a byte. anyway if you need to confirm system requirements you have to write to magento support.
    – MagenX
    Nov 16, 2015 at 10:38
2

Magento 2 limits its memory usage to 768M in the main .htaccess file: https://github.com/magento/magento2/blob/2335247d4ae2dc1e0728ee73022b0a244ccd7f4c/.htaccess#L40
This is the PHP-only limit for a single HTTP request. If your store need to serve 10 HTTP requests simultaneously then you need up to 10 * 768M = 7680M of memory for PHP interpreter only (in reality it is much lower because of cache usage, but there are some memory intensive tasks like compilation, reindexing, some 3rd-systems integrations which sometimes disable its memory limit at all and use a lot of memory).
Also you need some memory for other software environment: MySQL, web server, mail software, operating system, and so on.

2
  • 1
    10 HTTP requests simultaneously then you need up to 10 * 768M = 7680M WHOA... what a Saturday morning... if your application ever takes that much memory, well, then i would not be so sure about the quality of your extensions...
    – MagenX
    Nov 14, 2015 at 9:12
  • have you ever read that manual??? php.net/manual/en/ini.core.php#ini.memory-limit
    – MagenX
    Nov 14, 2015 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.