The Significance Of PHP Memory Limit

Rifat WordPress Tutorials Nov 29, 2022

Over time, every WordPress site owner and administrator will experience the following problem: It's that dreaded WordPress memory error again.

You're working away, uploading new media to your site, when all of a sudden, you get a warning reading, "Fatal error: Allowed memory capacity of xxxxxx bytes exhausted."

Just what took place? How did WordPress stop responding so abruptly?

The key is the PHP programming language, to put it briefly. As you add more media-rich and interactive elements to your WordPress site, you may find that you have reached the default memory limit for PHP code.

Create Amazing Websites

With the best free page builder Elementor

Start Now

In this article, we'll explain the WordPress PHP memory limit, why it's important, and how to boost it with Cloudways.

What is PHP Memory Limit?

The PHP memory limit is a standard memory limit that is set per_script and is enough for any web application. 128M set to a lower level. If PHP scripts try to use more than 128M, they will get errors saying that the memory limit has been reached.

Set the memory limit by running the phpinfo()function. This will show you the memory limit, which you can use to plan your server settings. The administrator of the server can set a memory limit as low as -1, which means that no memory is assigned to any measure.

PHP scripts aren't very big. Each script should only use a small amount of RAM unless you have an unusual application that needs more resources in one script than most programs will ever use in their entirety. There are plugins like these, but they aren't very common.

Why Is The Memory Limited?

If you give each process more memory, you may be able to run fewer processes at the same time. How many page requests you can handle at once depends on how many PHP processes you have running.

When PHP benchmarks processes get too busy, the memory limit is reached, servers have to be stopped by force before they crash completely, or all of your shared resources for the month are used up.

How Does Memory Limitation Relate To Performance?

Suppose three PHP scripts are occupying 100 MB of memory concurrently. All of that would use up 300 MB of memory, which is more than what PHP can handle. The RAM depends on how easy it is to get to the data that a preparation or script needs to run. So if you know you'll need more, 256 MB should be enough for the plugins that use the most memory.

When you use plugins that need more memory, be careful. Some web hosts set the PHP memory limit very low. This can cause the error to show up even if you're not installing an app that uses a lot of resources.

Increase the PHP Memory Limit

If your website needs more memory, you can create a php.ini (phprc) file and change the limit there. For example, to finish a process, you might need to do this.

But people who use Cloudways don't have to change the PHP.ini file or the wp-config file. Using the Cloudways Platform, they can just change the value in the settings for the app.

PHP Memory Limit with Cloudways

Every site is made to do something different. Depending upon this and the hosting nature you're using, you can change the PHP memory limit if you need. Once you have a good idea of how much traffic you get and how much memory your application uses, you can plan for future growth.

Cloudways does not force you to use a certain amount of memory. Just like PHP workers, we let the user decide how much memory they want to use.

Maximum PHP memory for a high-traffic e-commerce website

Learning the Harp is a busy online store that people from all over the world visit. At the moment, it needs 6000 MB of PHP memory to handle all the requests and traffic.

When your website is hosted on one server, each client that visits it sends requests to that same server. This means that when your website has a lot of visitors, it will take longer to handle each request, which will slow stack times for all of them. When the PHP memory limit is raised, servers can handle requests faster.

PHP memory limit for an LMS site that gets a lot of traffic

Pittsburgh Fresh is a meal delivery service (LMS) based in Pittsburgh, Pennsylvania, that focuses on delivering fresh, healthy, and easy-to-prepare meals. The LMS is run on Cloudways servers and gets a lot of traffic. To handle this, it uses about 2048 MB of PHP memory limit.

Most LMS sites are built with plugins that are heavy. A plugin with bad code or a theme that takes a long time to load can hurt your site's performance, making it take a long time to load and hurting the overall user experience. Increasing the amount of memory could help solve some of these problems.

PHP memory limit for a multisite with a lot of traffic

Google ranks Current Debate as one of the best sites for US business news. There are local businesses and national franchise brands among the readers. Current Debate is multisite that gets a lot of visitors. At its most, it uses about 16GB of PHP memory.

With multisite, all the resources can be used on a single website. It might need to have more memory in order to work better on both the front and back ends.

Conclusion

Most of the time, websites with mostly static content don't need a high PHP memory limit. The 128–256 PHP memory limit is a good place to start for larger websites with more complex features. Also, your memory limit should take into account the number of themes, plugins, database queries, and the proportion of cached to uncached files on your site.

Divi WordPress Theme