20i
PHP Workers and wordpress - how they impact your hosting performance

PHP Workers and WordPress: How they impact your hosting performance  

PHP Workers are an important factor to deliver high-performance hosting for PHP based apps. This is especially the case for WordPress, where they are used to handle all the background tasks, build webpages, query the database and more.  

In this article we’ll show you the importance of PHP workers, including what they are and why you need them. 

What are PHP workers? 

PHP-based tasks on a web server can often be resource intensive, especially for large or complex sites/apps. To help prevent delays and handle multiple requests, PHP workers are employed.  

A PHP worker refers to a process or thread that’s responsible for executing PHP code. When a request comes into a server to load a PHP page, a PHP worker takes that request, executes the necessary PHP code, and then sends back the appropriate response, for example, in the form of an HTML page. 

What is PHP-FPM? 

PHP-FPM manages PHP processes. Its main advantage is that it can handle a high volume of queries, making it especially useful for sites with heavy traffic or complex web applications.

PHP-FPM maintains pools of PHP processes that can serve PHP code without needing to start up a new PHP process for each request. 

PHP Workers and WordPress 

Here is a breakdown of what a PHP worker does when a non-cached request is made on WordPress website: 

  1. A visit to the WordPress page is made.  
  1. The webserver receives that request and then forwards it to the appropriate PHP Handler, in our case PHP-FPM 
  1. PHP-FPM assigns an available PHP worker to handle the request. The PHP workers load the WordPress core and any required plugins and themes  
  1. PHP Worker then processes the PHP code – this also involves database queries and any other required tasks.  
  1. The PHP workers generate the HTML content, which is sent back to the webserver. 
  1. The webserver sends the HTML response to the user’s browser over HTTP.  
  1. The browser renders the HTML, displaying the requested page.  

Combining PHP Workers with PHP-FPM (which greatly improves the response times of PHP environments), your website will be delivered faster and to more people at the same time. 

If a WordPress website contains bad coding and unneeded MySQL queries, this can cause congestion for PHP workers and take a lot longer to load. Even just one bad plugin on a fast server can really slow down the initial page speed load time. 

Why do you need PHP workers? 

The purpose of a PHP worker is to handle requests that do not hit the cached data of a website.  If the cache is missed, the PHP worker will process the request.  

For example, when multiple users access a WordPress website at the same time, the web server needs to handle all requests at once.  

Each user’s request is processed separately, and PHP workers help ensure that the website can respond to multiple users at the same time. 

What happens if you do not have enough PHP workers? 

For a fast and responsive website experience, it’s essential that your website has enough PHP workers.  

If a web server has too few PHP workers and gets too many simultaneous requests, it will queue up the excess requests until a worker becomes free. This can result in slow response times or timeouts for users. 

Each PHP worker consumes memory and CPU. So, there’s a balance between having enough workers to handle the traffic and not overwhelming the server’s resources. 

If your server runs out of PHP workers often, users may experience slowness. Monitoring the usage of PHP workers and server resources can help in making informed decisions about scaling or optimizing your server setup. 

When the available PHP workers become busy, they build a queue in the background and this can result in:

  • Slower web page load
  • Unresponsive pages
  • Database slowdown
  • Temporary downtime (502, 504 and other errors)

Obviously, this can cause a negative experience for visitors on the website and impact the website’s SEO.  

PHP workers allow your website to handle multiple requests all at once. This is key for maintaining a responsive user experience, especially during periods of high traffic. 

Here are a few tips on how you can mitigate these issues… 

Optimise your WordPress code 

Use quality plugins and avoid heavy themes. When choosing your plugins and themes, keep an eye on how often the developer has kept them updated. If the plugin or theme hasn’t been updated in many months, it’s probably best to avoid.  

WordPress likes to keep their core versions updated and new core versions are frequently released.

If a plugin or theme has not been updated for a long time, it’s likely to have fallen behind with WordPress core updates and conflict, causing performance and security issues for the website.  

Use Caching 

Caching stores static content which is delivered much more quickly and has zero impact on your server or PHP workers when requested, as the web server doesn’t need to send anything to PHP for processing to generate the page.  

Our WordPress Optimised Managed Cloud Hosting includes our bespoke cache plugin Stackcache and all plans include our own fully featured CDN.   

OPcache is an opcode cache. Opcode caching works by saving the compiled PHP code between every request.

Without an opcode cache, PHP scripts are loaded, parsed, compiled, and executed with every request, which can be a time-consuming process. This is built in for all our hosting plans.  

We offer Redis cache on our Managed Cloud Hosting range too. Redis stores MySQL queries which are executed, which means less database queries are requested resulting in faster load times and reduces server load.  

Choose a host who doesn’t cap PHP workers 

It’s common for Managed hosting providers to cap PHP workers on their hosting plans and only increase PHP workers when you upgrade the plan. For example, Kinsta offer 4 PHP workers on their ‘Business’ plan and 14 PHP workers on their ‘Enterprise’ plan at $1,100 /pm.  

With our Managed Cloud Hosting, you don’t need to worry about the number of PHP workers available or setting the number of PHP workers per website, they’ll be scaled to website traffic and server specification.   

Summary  

To conclude, PHP workers serve a pivotal role making sure that your WordPress website is fast and responsive under heavy load.

Finding a hosting provider who are performance focused is crucial as it’s common for Managed hosting providers to cap the number of PHP workers. 

Managed WordPress Hosting

Add comment