PHP FPM Worker

The PHP-FPM receives all requests for the PHP application and distributes them to individual PHP processes, also called workers

Background

The PHP-FPM (Fast Process Manager) takes all requests for the PHP application and distributes them to individual PHP processes, also called workers. This is necessary so that requests can be answered "in parallel". The number of PHP workers can be configured.
The FPM can only pass new requests to worker processes that are in "idle" status, i.e. not currently busy. If no free worker processes are available, the FPM waits until the next worker has finished its work and becomes free again or a timeout takes effect.
All requests that the FPM processes are received from the web server. This means that there is an HTTP request for each worker process and the response to these HTTP requests by the web server is largely dependent on the FPM.
It is therefore not intended that all PHP workers are busy and new HTTP requests must therefore wait. What is wanted, however, is that enough PHP workers are available and that the FPM finds free workers for each new request. At the same time, however, RAM and CPU resources must not be overloaded. The latter is also the reason why there must be a maximum number of workers.

To start the workers, there is a choice between several possible PHP schedulers:

  • The "Static" scheduler starts a constant number of PHP processes and makes sure that they run permanently. This scheduler is only maintained in a very rudimentary way and does not log, for example, when the workers are busy. For this reason, we do not offer it.
  • The "OnDemand" scheduler starts workers as soon as a request arrives and terminates the worker very quickly when it is no longer needed. This leads to some overhead when frequent requests come in, but also ensures that PHP only uses the necessary memory.
    The "OnDemand" scheduler is especially good for websites with low traffic.
  • The "Dynamic" scheduler, in contrast to the "OnDemand" scheduler, ensures that a certain amount of free workers are always available, so that requests can be answered without delay.
    The "Dynamic" scheduler is particularly suitable for websites with medium and high traffic.

Solution

The settings of PHP-FPM depend on the web application and the expected visitors.

If individual PHP requests can be executed quickly and require little RAM, it is possible to use more PHP workers than pages that make complex calculations within the PHP processes for the same resources. It should be ensured that sufficient RAM is available for all PHP workers in particular. For example, complex store systems such as Magento or Shopware require more RAM than simple CMS systems such as Wordpress or Typo3. In addition, it must be noted that some applications are based on many Ajax requests, which often occupy only a few resources.

You should therefore check on the one hand whether sufficient free working memory is available in operation, for example via hardware monitoring. For this, maxcluster offers a display in the Monitoring Center.
Secondly, you should check that no processes had to be terminated by the so-called OOM killer of the operating system. The entry can be found in the file /var/log/kern.log.

Furthermore, it must be checked that there are enough workers available. If the workers were full, you can see this by an entry in the log file of php-fpm. We recommend that you check whether the PHP workers are large enough, especially before marketing campaigns.

For your check, you can use the data in the following table as a basis for approximate classification:

Settings based on visitor behavior and memory

If you need assistance, our support team at support@maxcluster.de will be happy to review your configuration.

Do you need assistance?

favicon
maxcluster GmbH
24 / 7 Customer support
Telephone:
+49 5251 414130
E-Mail:
support@maxcluster.de
logo

Do you need assistance?

maxcluster GmbH
24 / 7 Customer support
Telephone:
+49 5251 414130
E-Mail:
support@maxcluster.de
image
image