In this Episode 5 of Ask Paul Anything, we’ll discuss what WP_MEMORY_LIMIT
is and how to use it.
Today, I’m going to answer the following question:
What should the
WP_MEMORY_LIMIT
and WP_MAX_MEMORY_LIMIT be? My site has 10,000 of daily visitors and runs on WordPress and WooCommerce. Also, does memory limit affect the speed of the website?
[0:24] – What Is WP_MEMORY_LIMIT
?
For those that don’t know, WordPress offers the option to use a PHP constant, called WP_MEMORY_LIMIT
, to set the maximum memory usage by PHP.
What does That Actually Mean?
Let’s assume your server has 1GB of memory and also that that 1GB is wholly available to PHP.
When someone loads a page, when PHP is instantiated, the maximum memory that that page PHP process can use is X. So, let’s say you set the memory limit to 128MB.
That means that, if your PHP processes all use of the full memory available to them (128MB), you’ll be limited to 8 concurrent PHP processes.
I’m not saying that you can have only 8 processes on your site at 1 time. What I’m saying is:
If each process uses the maximum amount of memory available to them, then that’s the maximum amount of concurrent processes that will be available to your server.
So, WP_MEMORY_LIMIT
does not mean that that’s the amount of memory that the PHP process will use. It’s the amount of memory that PHP process will be allowed to use.
[1:48] – How Does WP_MEMORY_LIMIT
Work?
If you set your memory too low, let’s say 32MB, and your site won’t load, in fact, it’ll probably crash. You’ll get a familiar message that the process exceeded available memory by xxx bytes.
Basically, if PHP goes over your limit, it will crash and nobody wants a crashing site. You would rather have the upper limit to be a little bit higher.
So, WP_MEMORY_LIMIT
is trying to restrain how big a memory footprint that a PHP process can actually make.
[2:43] – What Should The WP_MEMORY_LIMIT
Be?
If a site has 10,000 daily visitors and runs on WordPress and WooCommerce, there’s no way to know what the WP_MEMORY_LIMIT
is. But, it should be at least as big as it needs to be.
Sometimes when a person loads the page it uses 64MB but most of the time he uses only 50MB. Then, the minimum value you should put for your WP_MEMORY_LIMIT
is 64MB.
You should put your minimum value to be whatever the amount of memory that is required for every single page to work.
[3:30] – Does Memory Limit Affect The Speed Of The Website?
No, it doesn’t but in a certain way, it could.
If you make a PHP memory limit very large, then perhaps PHP will clean up after itself a little less often because it’s got so much memory to work with. But I would say no, WP_MEMORY_LIMIT
will not affect the speed of the website.
[04:02] – What Will Affect The Speed Of The Website?
What will affect the speed of your website is:
- how it’s configured;
- number of plugins you’re running;
- the number of visitors you have; and
- how powerful your server is.
What Do You Need Then?
If you have 10,000 of daily visitors on your site, you’re going to need a powerful server.
Changing the WP_MEMORY_LIMIT
won’t really affect that. What you’ll want to do is to increase the physical memory available to the system.
Thank You! Comments, Questions?
I hope that this gives a little bit of background on the WP_MEMORY_LIMIT
and how it works.
If you have any questions about this or any other questions of your own, please feel free to use the link below. We’d be delighted to answer to them. 🙂
If you’re on YouTube, click to subscribe. If you’re on Facebook, click to “Like” or share.