The PHP memory limit is the maximum server memory each PHP script can extend. Per the PHP documentation: “This sets the memory in bytes that a script is allowed to designate. This makes a difference in preventing ineffectively composed scripts from eating up all accessible memory on a server.”
The memory limit setting fixes a memory size for executing a script. It prevents ineffectively coded scripts on the server that designate superfluous space, thus sparing server memory during large-scale utilization of the application.
What is the PHP Memory Limit?
The PHP memory_limit is per-script, just as a standard memory limit that is enough for any web application. A lower setting of 128M. If PHP scripts attempt to utilize more than 128M, those scripts would presently return memory limit surpassed errors.
Set the memory limit set by executing the phpinfo() function to see the memory constrain and plan your server setting according to the value. The server administrator can set a memory limit from -1—no memory assignment to any measure.
PHP scripts are tiny. Every individual script should only take up a small amount of RAM, unless you’ve got an unusual application that needs more resources in one script than most programs will ever take in their entirety. These kinds of plugins certainly exist, but they’re uncommon.
Why Is There a Memory Limit?
Increasing the memory of each process can decrease the number of concurrent processes that can run. PHP processes are critical to the maximum number of page requests you’ll serve at any given time.
When PHP processes get overloaded, the memory limit, servers have to force stop before they completely crash, or all your distributed resources for the month get consumed.
Stop Wasting Time on Servers
Cloudways handle server management for you so you can focus on creating great apps and keeping your clients happy.
How Does PHP Memory Limit Relate to Performance?
Say 3 PHP scripts are utilizing 100 MB of memory each at the same time. That would add up to 300 MB of memory utilization, and a PHP limit of 128 MB wouldn’t be enough. The RAM depends on the accessibility of the data required to run a preparation or script. So if you know you’ll require more, 256 MB should cover the heaviest plugins.
Be careful when using plugins that need additional memory. Some web hosts set the PHP memory limit exceptionally low, so that can cause the mistake to appear even when you’re not installing a power-hogging application.
How to Increase the PHP Memory Limit
If your website’s needs necessitate increasing the memory limit, to complete a process, for instance, you’d need to create a php.ini (phprc) file and increase the limit there.
But Cloudways users don’t need to edit the PHP. ini file and wp-config file. They can just change the value from within the application settings using the Cloudways Platform.
The PHP Memory Limit with Cloudways
Every site is built to serve a different purpose. You can vary the PHP memory limit you need based on this and the hosting environment you’re using. Once you get a baseline on your traffic volumes and the memory limit your application is using, you can plan for scalability in the future.
Cloudways does not limit you to a fixed memory limit size. Just like with PHP workers, we let the user increase the memory limit according to their needs.
PHP memory limit for a high-traffic ecommerce site:
Learning the Harp is a high-traffic ecommerce store accessed from around the world. Currently, it uses 6000 MBs of PHP memory to handle the traffic and requests.
When your website is hosted on one server, each client who visits it sends requests to that same server. This implies that when your website experiences high levels of traffic, the time it takes to handle each request increases, slowing down stack times for all of them. An increased PHP memory limit helps servers to handle requests more efficiently.
PHP memory limit for a high-traffic LMS site:
Pittsburgh Fresh is an LMS based in Pittsburgh, PA, that focuses on delivering fresh, healthy and convenient meals. Managed on Cloudways servers, the LMS sees exceptionally high traffic and uses about 2048 MBs of PHP memory limit to handle this.
Most LMS sites are built using heavy plugins. A poorly coded plugin or slow-loading theme can impact your site’s performance that results in extensive load time and affect overall user experience. A higher memory limit could help mitigate these problems.
PHP memory limit for a high-traffic multisite:
Current Debate is a top-ranked website on Google for US business news. The readers include local businesses and national franchise brands. A highly visited multisite, Current Debate uses around 16GB of PHP memory at max.
With multisite, one website has access to all the resources. To optimize performance on both the front and back ends, it might need to increase its memory limit.
Conclusion
In general, websites with essentially static content don’t require a large PHP memory limit. 128 – 256 PHP memory limit is a great starting point for bigger websites with more energetic functionality. That said, your memory limit should account for your website’s set of themes, plugins, database queries, and cached-to-uncached proportion.
Customer Review at
“Cloudways hosting has one of the best customer service and hosting speed”
Sanjit C [Website Developer]
Shahzeb Ahmed
Shahzeb is a Digital Marketer with a Software Engineering background, works as a Community Manager — PHP Community at Cloudways. He is growth ambitious and aims to learn & share information about PHP & Laravel Development through practice and experimentation. He loves to travel and explore new ideas whenever he finds time. Get in touch with him at [email protected]