← All insights
ENGINEERING JOURNAL / Web Server Engineering

PHP-FPM Slow Logs: Capture the Waiting Request Stack

Enable a scoped PHP-FPM slow-log investigation, correlate backtraces with real requests and distinguish a sampled waiting stack from a completed root-cause analysis.

PHP-FPM Slow Logs: Capture the Waiting Request StackPHP-FPM Slow Logs: Capture the Waiting Request Stack — conceptual 3D-style vector showing Slow request, FPM pool, Running worker, Slow-log stack, Dependency timing, Application fix.. Conceptual teaching illustration; connections show the investigation flow rather than a vendor deployment topology.CLOUVENIX / WEB SERVER ENGINEERINGPHP-FPM Slow Logs: Capture the Waiting Request Stack01Slow request02FPM pool03Running worker04Slow-log stack05Dependency timing06Application fixConceptual investigation flow / PHP-FPM Slow Logs: Capture the Waiting Request Stack
PHP-FPM Slow Logs: Capture the Waiting Request Stack — conceptual 3D-style vector showing Slow request, FPM pool, Running worker, Slow-log stack, Dependency timing, Application fix.

Context

A PHP request takes much longer than expected, but the web-server log shows only the final duration. PHP-FPM's slow-log facility can capture a backtrace from a request that exceeds a configured interval. That stack gives a place to investigate; it does not automatically measure every dependency or prove why the request was slow.

Prepare the exact PHP-FPM version, affected pool, request identifier and a controlled reproduction. Determine who may read stack traces, because they can expose code paths and business identifiers. Start in staging where possible and use the smallest pool and collection window that can answer the question.

Configure a bounded observation

  1. Map the web request to the actual FPM pool and configuration file. Different applications can use separate pools with separate identities and logs. Review the installed binary and service unit before selecting a validation command. A CLI PHP configuration dump does not establish which pool handles the slow web request.
  2. Inspect slowlog, request_slowlog_timeout and supported trace-depth settings in the installed FPM configuration. The upstream sample identifies a slow-log destination when slow-request logging is enabled. Choose the interval from the observed problem and normal request distribution, not from a universal tutorial value. Keep ordinary error logging available as a separate signal.
  3. Confirm that the log destination and trace mechanism work under the pool's deployment model. Filesystem access, container boundaries or process-inspection restrictions can prevent backtrace capture. Review FPM error messages for collection failures rather than concluding that a missing slow-log entry proves the request was fast.
  4. Validate configuration using the versioned FPM binary's supported test option, then activate through the normal service procedure. Reproduce one harmless slow operation and correlate the captured stack with access-log timing and application request IDs. Keep the raw stack restricted and share a sanitized excerpt with the code owner.

An illustrative lock-wait stack

In an illustrative invoice endpoint, a slow-log backtrace repeatedly stops near a database call. That observation narrows the request's location but does not distinguish database execution from waiting for a connection or a database lock. The next step is to correlate the request with database-side evidence, not immediately add more PHP workers.

ObservationAdditional evidenceInterpretation
No slow-log entryPool, threshold and trace errorsCollection may be misconfigured
Repeated dependency frameDependency timing and server evidenceWaiting boundary identified
Different stacks each captureRequest shape and code pathMultiple causes or sampling points
Request continues after traceTermination policySlow logging is observational

Correct the demonstrated request path

Work with the application owner on the specific dependency, lock or computation indicated by corroborating evidence. Keep slow logging distinct from request_terminate_timeout; terminating requests changes application behavior and can leave side effects that need separate design. A stack-capture threshold is not an application deadline.

Verify the same operation under comparable input and concurrency after the correction. Compare completion time, application correctness and dependency behavior. The absence of new traces is useful only if the collection still works and the representative workload was exercised.

Maintain a tracing SOP

Document pool ownership, safe log location, collection window, retention and the process for removing temporary diagnostics. Monitor trace-write errors and correlate slow requests with business impact. Review whether ongoing sampling is useful after the incident. Clouvenix server performance can help turn a stack snapshot into a focused application investigation.

Technical reference

Upstream FPM pool configuration, PHP FPM directive documentation and FPM feature overview.