Process manager modes
pm=dynamicfor most apps;pm=staticonly when workload is predictable and memory bounded.- Key knobs:
pm.max_children,pm.start_servers,pm.min_spare_servers,pm.max_spare_servers. - Size
max_children= (available RAM - OS/webserver/DB) / avg worker RSS.
Opcache
- Enable:
opcache.enable=1,opcache.enable_cli=0,opcache.memory_consumptionsized for codebase,opcache.interned_strings_buffer,opcache.max_accelerated_files. - Avoid
opcache.revalidate_freq=0in prod unless you control deploy restarts; prefer deploy-triggered reloads.
Timeouts & queues
- Keep
request_terminate_timeoutsane (e.g., 30s-60s); long requests move to queues. - Use
pm.max_requeststo recycle leaky workers (e.g., 500-2000). - Watch slowlog to catch blocking I/O or heavy CPU.
Observability
- Export
status_pathand scrape: active/idle/slow requests, max children reached. - Correlate with Nginx/Apache logs for upstream latency and 502/504s.
- Alert on
max children reached, slowlog entries, and rising worker RSS.
Checklist
- Pool sizing validated under load test.
- Opcache enabled and sized; reload on deploy.
- Timeouts/queues tuned; slowlog on.
- Status endpoint protected and scraped.