Skip to content

Performance monitoring

PHP performance monitoring

PHP handles each request in a fresh worker, so performance depends on worker capacity, OPcache and how long each request waits on the database.

3 min read10 sectionsUpdated

On this page

PHP-FPM status

www.confplaintext
; www.conf
pm = dynamic
pm.max_children = 20
pm.status_path = /fpm-status
request_slowlog_timeout = 5s
slowlog = /var/log/php-fpm/slow.log
FieldWatch for
active processes vs max childrenClose to max for minutes: requests queue
listen queueAbove zero: requests waiting for a worker
max children reachedIncreasing: raise max_children if memory allows, or make requests faster
slow requestsEntries in the slowlog with stack traces

OPcache

Check opcache_get_status() for the hit rate and memory usage. In production, enable OPcache, give it enough memory for all scripts, and set opcache.validate_timestamps=0 with a reload on deploy, so scripts are not checked on every request.

Typical PHP bottlenecks

  • Too few FPM workers, or too many for the memory available (each worker uses tens of MB).
  • N+1 queries in Eloquent or Doctrine; eager-load relations.
  • External API calls without timeouts blocking a worker for 30 seconds.
  • Sessions in files with locking, serializing concurrent requests from one user.
  • Autoloader and config not cached in Laravel (php artisan config:cache, route:cache).

Tracing

Install the opentelemetry PHP extension and the auto-instrumentation packages, then configure with environment variables, including in the FPM pool. The full setup is in OpenTelemetry for Laravel.

What to watch in PHP applications

SignalSourceWhy
Request latency per routeOpenTelemetry tracesFind the slow endpoints
PHP-FPM active processes and listen queueFPM status page (pm.status_path)A full pool means 502s and queued requests
max_children reachedFPM log and statusThe pool is too small or requests are too slow
Slow requestsrequest_slowlog_timeout and slowlogStack traces of requests over the limit
OPcache hit rate and memoryopcache_get_status()A full OPcache recompiles scripts on every request
Database time per requestDatabase spans in tracesMost PHP slowness is queries
plaintext
; php-fpm pool config: status page and slow log
pm.status_path = /fpm-status
request_slowlog_timeout = 5s
slowlog = /var/log/php-fpm/slow.log

Instrumenting PHP

The OpenTelemetry PHP extension with auto-instrumentation covers common frameworks and clients; see OpenTelemetry for Laravel for a step-by-step setup. Watch for N+1 queries in ORMs: one page that runs hundreds of small queries shows up clearly as a long list of database spans in a single trace.

Frequently asked questions

How do I size pm.max_children?

Divide the memory you can give PHP by the average worker memory (check RSS of workers under load), leaving headroom for the OS and other services.

Is JIT worth enabling?

For typical web apps waiting on I/O, gains are small. It can help CPU-heavy code. Measure before enabling in production.

Check it now, free

  • Python performance monitoring: Monitor Python web apps: request latency per route, worker saturation, the GIL and CPU-bound code, database time, Celery queues and memory.
  • Java performance monitoring: Monitor Java and Spring applications: JVM heap and GC, thread pools, JDBC connection pools, request latency from traces.
  • Best APM tools: Choose an APM tool in 2026: the criteria that matter, from OpenTelemetry support to pricing models, well-known options compared and how to run a fair trial.
  • What is APM (application performance monitoring)?: APM explained: what application performance monitoring measures, how traces and spans work, why p95 beats averages, a worked example and how to start.
  • IIS monitoring and IIS logs: Monitor Microsoft IIS: performance counters, request queues, application pool health and recycling, W3C log fields such as time-taken.
  • OpenTelemetry for Flask: Instrument a Flask app with OpenTelemetry, in code or with zero code: trace routes, SQLAlchemy and outgoing calls, and export to VitalRix.

Watch your own site and services with VitalRix

Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.