Nexcess
Nexcess Blog Logo
November 14, 2019

What are PHP Workers and Why You Should Care

Have you ever browsed through your favorite coffee shop’s website and as you check out with that new order of coffee, you end up getting a 504 error after a delay?

Or maybe you were browsing your favorite sports website and as you try to load the next page, it takes a while to load and comes back with a timeout error?

These situations are frustrating, and not what we expect when we look at a site. In both cases, the cause may be not having enough PHP workers allocated to a site. Without enough PHP workers, a site can’t process all site requests that come in if there are a higher number of them. It’s not a good situation, as site speed is incredibly important for converting visitors to sales leads and customers.

What is a PHP Worker?

What is a PHP worker? PHP workers build pages and handle requests that require backend processing on your site. PHP workers are directly responsible for generating HTML pages for your site visitors. Because of this, they determine how many uncached requests a website can process at any given time.

This is usually active tasks like an inventory check on a specific item or it could be something as complex as viewing and listing all prior orders for a customer. When a PHP worker is started, it remains persistent until processes are completed or certain conditions are met.

Think of PHP workers as a check-out line at a grocery store where each item that is to be scanned is a PHP process.

If you only have one PHP worker (one checkout line) then everything must go through that single checkout lane, and the cashier can only work through one order at the time. PHP workers can limit the number of concurrent, or simultaneous, transactions on a site. As previously mentioned, if you have only four PHP workers (four checkout lines) the site can only process four transactions at once.

The 2021 Essential Guide to WordPress Plugins >>

However, this does not mean that the fifth customer (PHP process) or beyond does not get processed. PHP processes are placed in a queue for the worker which means it processes the first request in line then moves onto the next PHP process in the queue. In other words, a long line forms and people start waiting.

Luckily, PHP workers process the information faster than grocery store cashiers. They work very quickly and can clear many and most processes within milliseconds. By having only a few additional PHP workers, you are able to have many more concurrent processes that can be run at one time, meaning more customer orders can be processed at once.

What Happens When You Have Too Few PHP Workers Per Site

Let’s say you have only two PHP workers on a site and you have several plugins and a heavy theme. Those two PHP workers will constantly be used only to process plugins and theme processes leaving a queue to build up immediately for new page requests from visitors to your site.

If you are running an ecommerce site on top of this, it will only increase the queue amount. Much like customers waiting in line, some PHP processes will abandon the line. Processes that are not written to abandon the line, or time out, and will sit and wait. Then, they will begin to put a much higher load on server resources. It’s like the checkout line is now wrapping around the block!

PHP processes on a WordPress website can be as simple as the submission of a contact form or a request to geolocate a visitor based upon their IP or zip code.

For eCommerce websites, this can look a little different. Items such as new orders being processed, carts, and customer logins would all utilize PHP workers. The products or descriptions will usually be cached so that generally would not require a PHP process for viewing. Having only three to five PHP workers means that you can only have that many simultaneous transactions on the website and that the PHP workers will process requests in the order they were triggered (just like a shopping line).

How To Lighten The Load For Your PHP Workers

A common problem area to start with for PHP workers is having too many plugins and heavy themes. You can generally help alleviate issues caused by a bloated website with these tips:

  1. Add site caching with a plugin
  2. Reduce external calls to remote sites
  3. General site optimization

Site optimization can get complicated, especially with sites that experience heavier traffic which requires more attention to detail. Generally, the larger the site, the more efficient the site must be in the way it requests its styles, products, orders, and customers. This way, you utilize the PHP workers for general site functionality less and PHP workers can process what matters — your traffic — effectively.

Nexcess plans come with enough concurrent users for even the largest of sites to manage traffic.

With Nexcess, you already have 20 concurrent users as part of an XS plan. This increases in increments of 20 as you move up to the XXL plan (which has 120).

Beginner’s Guide to WordPress Performance Optimization >>

Other managed application platforms offer anywhere from two to four PHP workers in introductory offerings. Nexcess Managed WordPress and WooCommerce also have server-side caching built-in which helps minimize the use of PHP workers to process static content, allowing the PHP workers to process requests from the people who matter most: your customers.

Maintain a Faster Site with More PHP Workers

PHP workers can manage thousands of processes each, however; many factors come into play, including:

  • How many exterior calls are they making?
  • How many plugins are competing with inquiries to the database?

Additionally, adding PHP workers to a site will also increase the resource allocation being used from the server. The more PHP processes running, the more RAM and CPU allocations will be needed, thus creating heavier loads on the server and having as much optimization as possible can reduce that server load. PHP workers are key, but they are not magic, one-size-fits-all solution.

The more plugins (even inactive ones), the more PHP workers are utilized to process non-static requests. The same applies to heavily featured themes.

For this reason, it is always a good idea to use caching and a content delivery network (CDN) to help reduce the task load for PHP workers. This will optimize your site to process customer requests in the fastest manner possible.

Better is Built In With Fully Managed Hosting from Nexcess

Improving your website’s performance starts with high-quality hosting. With Nexcess Fully Managed WordPress and WooCommerce hosting, you get:

  • Automated scaling to keep your site fast during traffic surges.
  • Automatically optimized images for fast loading times.
  • Lightning fast load times thanks for our built-in CDN.
  • And more!

See why users gave us a 4.6 out of 5 star rating on Trustpilot. Experience optimized hosting for your site. Start your free two-week trial today.

Avatar for Chris
Chris
With almost a decade in systems experience, Chris is here to make clients happier with the services they use. If there’s a technical problem, chances are Chris is one of the team members working on it, having already made tens of thousands of sites run better with the infrastructure improvements he’s helped develop.