Hosting & Deployment

Tune PHP-FPM and Web Server Capacity from Evidence

Size PHP workers and web-server limits using measured concurrency, memory use, and request duration.

PHP-FPM capacity is a balance between concurrency and available memory. Raising worker counts without measurement can cause memory pressure, swapping, and worse latency.

Measure worker memory

Observe real PHP-FPM worker memory under representative requests. Account for variation between lightweight pages and memory-intensive conversions or reports. Use a safe memory budget that leaves room for the database, web server, operating system, and other services.

Understand queueing

If all workers are busy, requests may wait in the listen queue. Track active and idle workers, max children reached, request duration, and queue length. A saturated pool may indicate slow dependencies rather than insufficient worker count.

Separate workload classes

Long-running exports or conversions may need a dedicated pool or background worker instead of occupying ordinary web workers. Apply execution limits and resource controls appropriate to each workload.

Change one variable at a time

Adjust process limits, timeouts, and web-server concurrency in controlled steps. Compare latency and resource use after each change.

Checklist

  • Measure worker memory and request duration.
  • Watch queue length and max-children events.
  • Leave host-level memory headroom.
  • Isolate long-running workloads where practical.
  • Tune incrementally and verify outcomes.
Share this page Help other developers discover this resource.