Table of contents of the article:
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
An effective solution to avoid bottlenecks in web applications is to set up separate PHP-FPM pools for the frontend and backend , each with distinct parameters for handling requests and resources.
To understand the concept, imagine running a bar with a single bathroom shared between customers and employees. At certain times, such as during a crowded party, you might find yourself with a long line: customers have to wait for employees to finish, and vice versa. This creates inefficiencies and poor service , slowing down staff and compromising the customer experience.
This is why many establishments adopt a practical division: separate bathrooms for customers and staff , so as to avoid interference and conflicts of use.
Likewise, even in the server environment, it's best not to mix frontend and backend applications in the same PHP-FPM pool . Operations performed by the backend—often slower and more intensive, such as report exports or administrative processing—can saturate resources and slow down responses to frontend requests, which are related to the user experience (page loading, checkout, login, etc.).
By separating the two environments into separate pools, you ensure that slow backend operations do not block frontend user traffic , improving stability, responsiveness, and overall quality of service.
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 { # More server directives... 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$ { # Other FastCGI directives... include fastcgi_params; fastcgi_pass $fpm_socket; fastcgi_index index.php; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } } 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.