Separate your slow backend from important front end traffic with PHP-FPM - 🏆 Managed Server
June 20 2022

Separate your slow back-end from important front-end traffic with PHP-FPM

Let's see some tricks on how to create two PHP process queues, one for the frontend and one for the backend.

Backend Frontend

If you are using WordPress, WooCommerce, Magento, Shopware, Oxid, a CMS or any other standard software, usually both the frontend and the backend use the same application fpm pool. Even for self-developed applications with Symfony or other frameworks this is often the case.

The backend / administrator can therefore include many slow operations, administrative operations and data exports that can take a long time. This could congest the web servers' processing queue reducing throughput for your customers who might just click the payment button and see a 502 Bad Gateway error.

Putting frontends and backends on different physical servers is a solution, but it can be too expensive for most use cases as we are effectively doubling the costs for the two machines or instances.

PHP-FPM Pool separation between frontend and backend

A simple solution to this problem is to use different PHP-FPM pools for the frontend and backend, each with their own configuration for the maximum number of requests allowed.

For example, imagine that you are the owner of a bar and have only one bathroom used by both customers and employees. Unpleasant situations can occur, in which the customer has to wait for the employee to finish in order to use the bathroom, or the case of a very large queue of people, perhaps at a party, and the employee who must necessarily get in line and wait for the its turn.

You understand that such a dynamic creates significant disservices and problems for both the employee and the customer. In fact, because of this it is now common practice to see public establishments equipped with toilets reserved for customers and toilets reserved for employees so as not to have to "mix" the queues and the related priorities.

The same principle can be used at the server level when we want to separate the frontend part from the backend part.

Magento administration and frontend example

How does it look? Let's use Magento as an example, you can set up two pools in php-fpm.conf:

; php-fpm.conf [frontend] listen = /var/run/php-fpm-frontend.sock pm = static pm.max_children = 50

[backend] listen = /var/run/php-fpm-backend.sock pm = ondemand pm.max_children = 5 pm.process_idle_timeout = 5 

The frontend is configured for up to 50 concurrent requests and the backend for up to 5 concurrent requests. Back-end workers are created on demand and front-end workers are static to avoid fork overhead. I will discuss the differences between PHP-FPM pool configurations in a future blog post.

You can then change the Nginx vhost configuration for Magento installation with the following switch:

server {     // ....

    set $fpm_socket "unix:/var/run/php-fpm-frontend.sock";

    if ($uri ~* "^/admin/") {         set $fpm_socket "unix:/var/run/php-fpm-backend.sock";     }

    location ~ .php$ {         // ...

        fastcgi_pass $fpm_socket;     } } 

Based on the ^/adminpath in the request uri, it will now select the different PHP FPM pool and the frontend and backend will no longer compete and steal each other's resources.

If instead we were working with WordPress or WooCommerce the path would be ^ / wp-admin.

What matters is obviously the concept behind it, which is the ability to create separate and path-based queues.


Do you have doubts? Not sure where to start? Contact us

We have all the answers to your questions to help you make the right choice.

Chat with us

Chat directly with our presales support.


Contact us by phone during office hours 9:30 - 19:30

Contact us online

Open a request directly in the contact area.

INFORMATION is the leading Italian provider of high performance hosting solutions. Our subscription model is affordable and predictable, so customers can access our reliable hosting technologies, dedicated servers and the cloud. also offers excellent support and consulting services on Hosting of the main Open Source CMS such as WordPress, WooCommerce, Drupal, Prestashop, Magento.


Would you like to see how your WooCommerce runs on our systems without having to migrate anything? 

Enter the address of your WooCommerce site and you will get a navigable demonstration, without having to do absolutely anything and completely free.

No thanks, my customers prefer the slow site.
Scroll to Top