php runtime ai_generated true

WARNING: [pool www] server reached pm.max_children setting (5), consider raising it

ID: php/fpm-pool-exhausted

Also available as: JSON · Markdown
85%Fix Rate
88%Confidence
75Evidence
2023-01-01First Seen

Version Compatibility

VersionStatusIntroducedDeprecatedNotes
83 active

Root Cause

PHP-FPM pool exhaustion occurs when all worker processes are busy handling requests, causing new requests to queue or fail. This is typically caused by slow scripts, blocking I/O operations, or insufficient worker count for the traffic level.

generic

Workarounds

  1. 88% success Calculate pm.max_children based on available memory and per-worker usage
    Determine average worker memory: ps --no-headers -o rss -C php-fpm | awk '{sum+=$1} END {print sum/NR/1024"MB"}'. Set max_children = (available_ram_MB - other_services) / avg_worker_MB. Use pm = dynamic with pm.start_servers, pm.min_spare_servers, pm.max_spare_servers tuned accordingly.
  2. 85% success Identify and optimize slow scripts that block FPM workers
    Enable PHP-FPM slow log: slowlog = /var/log/php-fpm/slow.log, request_slowlog_timeout = 5s. Analyze the log to find scripts that take too long. Optimize by moving slow operations (external API calls, heavy database queries) to background queues.

Dead Ends

Common approaches that don't work:

  1. Raising pm.max_children to hundreds without considering available memory 72% fail

    Each PHP-FPM worker consumes 20-50MB of RAM. Setting max_children too high can exhaust system memory, triggering the OOM killer which will kill random PHP workers and cause more severe failures.

  2. Switching to pm = ondemand for high-traffic production servers 60% fail

    ondemand mode spawns workers on each request and kills them after idle timeout. Under sustained load, the constant fork/kill cycle adds overhead and increases response latency compared to pm = dynamic or static.

Error Chain

Leads to:
Preceded by:
Frequently confused with: