X
X

Select Your Currency

₺ Türk Lirası $ US Dollar
X
X

Select Your Currency

₺ Türk Lirası $ US Dollar

Server Optimization: How to Adjust PHP-FPM Worker Settings

HomepageArticlesTechnical GuidesServer Optimization: How to Adjust ...

For server optimization, first determine whether the bottleneck is CPU, memory, the request queue, or the database instead of increasing the number of PHP-FPM workers at random. This guide explains safe measurement, single-variable configuration, verification, and rollback steps for sites using PHP-FPM on Linux servers with administrative access. Shared hosting users may not be able to access the same settings.

Define the environment and limits before making changes

Before starting, verify the server’s operating system, PHP version, PHP-FPM pool name, and whether the web server routes requests to that pool. This information is usually available in the server control panel, service-status screen, or PHP-FPM configuration view. If the shared hosting panel shows only limited settings such as the PHP version and memory, worker management belongs to the provider; do not try to change the administrator-level configuration.

Record the current worker settings, memory limits, and service status before making a change. Before editing the relevant configuration file, use the backup method provided by the provider or operating system. Do not change the web server, PHP-FPM, database, and kernel settings at the same time; otherwise, it will be impossible to determine which change produced the result.

Separate the bottleneck for server optimization

First, note when the same problematic URL or operation is run. During the same time interval, inspect CPU usage, available memory, swap space, and disk-wait values on the system resource screen; on the PHP-FPM status or log screen, also inspect active workers, waiting requests, and pool-limit warnings. The names and locations of the error log, access log, and PHP-FPM log may vary by distribution and control panel.

If requests are waiting, the system records that the worker limit has been reached, and memory is still comfortable, the problem may be pool capacity. By contrast, if the CPU is constantly full, adding workers may increase processor contention instead of reducing waiting. If available memory is falling and swap usage is rising, it is safer to keep the current worker count and examine the heavy PHP operation or application-level load rather than opening more workers.

For example, on a hypothetical product site, requests may wait only when a payment report is opened. If, during the same minute, the PHP-FPM pool shows waiting requests and a pool-limit warning while CPU usage is moderate and memory is sufficient, a small worker increase may be considered first. If memory is being exhausted and swap usage is rising in the same observation, the decision changes: do not increase workers; examine the report query, caching, or processing time.

Change PHP-FPM worker settings in a controlled way

On a Linux server with administrative access, open the configuration screen or file for the relevant PHP-FPM pool. Evaluate pm, pm.max_children, and the startup, idle, and per-request time limits associated with the selected process-management model together. The version and distribution may change the available options and the reload method, so follow the panel’s validation feature or the distribution’s documentation.

  1. Record the pool limit: Note the active-worker and waiting-request indicators. If there is no limit warning, increasing max_children is not the right first step; investigate application or database latency.
  2. Make one small change: If memory is adequate, the CPU is not overloaded, and the pool appears saturated, increase only the worker upper limit for the relevant pool by a limited amount. Do not change the startup and idle-worker values at the same time. Save the configuration and confirm that the panel’s syntax validation succeeds.
  3. Reload the service safely: Use the reload or configuration-apply action recommended by the platform; do not run arbitrary service-stop commands. A successful result means that no configuration error occurs and that existing connections are preserved according to the platform’s behavior. If validation fails, do not apply the change and restore the old value you recorded.
  4. Run the same operation again: Under similar conditions, run the URL, report, or API request used in the initial observation again. Note the time of the repeat and inspect only the PHP-FPM and system records from this new time interval. If waiting requests decrease while memory remains safe, the change may have achieved its goal.
  5. Decide based on the new finding: If waiting does not decrease but CPU usage rises, roll back the worker increase; this result indicates a processor or application-processing-time bottleneck. If memory and swap conditions worsen, return to the old value. If a particular PHP operation or database query stands out in the new record, investigate that operation separately instead of changing the worker count again.

When should you not increase the value?

The worker count does not represent unlimited capacity because each worker consumes memory for its PHP process and the extensions it uses. If the server has multiple PHP-FPM pools, the upper limit of each pool can increase total memory pressure. If dynamic pages respond quickly but disk wait or database connection time is rising, a PHP-FPM setting will not solve the underlying cause.

The decision is simple: if the pool is saturated, memory is comfortable, and CPU usage is at an acceptable level, measure after making a small increase; if the pool is not saturated or memory is under pressure, do not change the worker value. After the change, verify the same operation using the new log records. If the problem continues, restore the old value and examine the specific delay recorded in the application or database layer.

The next safe step

If you do not have administrative access to your server, instead of asking the provider for the current PHP-FPM settings, first record the time when the problem occurred, the URL, and the observed symptom. If you do have administrative access, choose only one pool and one setting for the first implementation; preserve the value from before the change and compare it with the records from the new time interval. If you are evaluating different server options, you can also review the server rental options page separately.


Top