...

PHP-FPM Slowlog: Investigating Slow Requests Using `request_slowlog_timeout`

If you search for „slow request timeout,“ the corresponding PHP-FPM directive is request_slowlog_timeout. You place them in the pool that processes the relevant HTTP request, and set slowlog Specify the file destination. When the threshold is reached, FPM attempts to log the current PHP call stack. The threshold does not abort the request. The backtrace shows you where PHP was in the call stack when the error was logged. It doesn't tell you how long PHP had been there—for that, you'll need a specific timing measurement.

A backtrace instead of a request termination

Anyone looking for „slow request timeout“If you're looking for PHP-FPM, you need the directive request_slowlog_timeout. The spelling slow_request_timeout is not a valid name for this setting. The key difference from a timeout limit is this: If a request reaches the threshold, PHP-FPM attempts to capture its PHP call stack and write it to the slowlog. The slowlog threshold itself does not terminate the request.

Suppose an HTTP request for an order summary is currently waiting on a database call. If FPM captures the stack at that moment, the Backtrace show where PHP is located in the call chain and which functions the application used to reach that point. This is particularly helpful when using a shared entry script: The script name alone does not reveal whether the order overview or another function of the application is currently being executed.

This entry thus answers the question „Where was PHP when the data was captured?“, but not „Where did all the time go?“. The database query could have been running since the beginning of the request or could have started just before the data was captured. The stack trace shows neither how long this operation takes in total nor how much time elapsed beforehand for calculations or other database accesses.

Therefore, use the PHP-FPM slowlog to narrow down the next measurement during PHP debugging. In the example, it would make sense to measure the duration of the relevant call in the application and compare it with the database’s runtime data. This way, you can verify whether the observed section actually accounts for a large portion of the response time, rather than being caused by a single Snapshot to infer the cause.

Which FPM pool processes the request?

First, trace the path of the specific HTTP request. What matters is not whether PHP-FPM is installed on the server, but whether the web server actually forwards the request in question to this instance via FastCGI. For example, if an upstream cache fully satisfies the request, it never reaches an FPM worker. Therefore, the slowlog cannot provide a PHP stack for this call.

In nginx, you check the FastCGI forwarding settings that apply to the host and request path. Shows fastcgi_pass for example, on a Unix socket For the store, search the loaded FPM configuration for the pool whose listen specifies the same socket path. A second pool for administration can have its own socket. If you only change its settings, you won't capture any slow shop requests.

AI-generated stock image of two network cables plugged into adjacent ports on a patch panel, shown in a close-up, angled view
The AI-generated icon represents the unique mapping of the FastCGI target to the pool that processes the request.

The Slowlog directives belong in the Pool Configuration the competent FPM authority, not in the php.ini or in the application code. If you are using multiple PHP versions or separate services, check which instance is actually handling the socket and which pool file it is loading. A plausible filename is not enough: A change to the configuration of another instance has no effect on the request in question.

A call via the PHP CLI bypasses the web server and the FPM pool. Even if it executes the same script and takes about the same amount of time, it does not check the FPM slowlog. To verify functionality, an HTTP request must be routed through the designated web server and its FastCGI mapping to the relevant pool.

If you don't have access to the pool configuration with managed hosting, ask the provider for temporary access to the affected pool. To do so, specify the affected route and the narrowest possible time window during which the delay occurs. If no slowlog is available, ask for existing runtime data for these requests. While this data does not replace a stack trace, it can help identify which requests are suitable for further measurement.

What the Slowlog Threshold Reveals About Response Time

The Slowlog Threshold is a diagnostic setting for the FPM pool. The PHP Manual describes it as a time limit; once this limit is exceeded, FPM writes a PHP backtrace to the slowlog. The entry shows the call stack at the time of logging. It does not include timestamps for the individual functions and does not prove that the topmost call was already running when the threshold was exceeded.

The PHP 8.4.1 release source code sets the time base when entering the header-reading phase of the worker. The timeout check compares the time elapsed since then with the slowlog threshold and triggers the trace only during the execution phase and at most once per request. The threshold therefore does not determine an exact time of detection. Wait time at the listener before the request is taken over by the worker is not included in this time base. Check other versions and vendor packages separately.

The response time observed in the browser is not evidence of a slowlog event. For example, a request might be waiting for a free worker. Therefore, when investigating a slow response, use the FPM access log to check the duration as measured from FPM’s perspective and the internal status page for indications of waiting requests. The slowlog answers a different question: Where was PHP at the time of logging?

Compare backtraces from similar requests instead of reconstructing the flow from a single stack trace. If the same call site appears repeatedly, it is a useful measurement point. To determine its share of the execution time, measure the duration of the operation itself and compare it to the duration of the respective request.

Setting Up and Testing the PHP-FPM Slowlog

Enter the following directives into the actual loaded configuration of an existing pool in an isolated test environment. The two seconds are a Test threshold, not recommended for production use. The log path is just an example: Check whether the directory exists on your system and whether the destination is usable for the relevant FPM instance. The file should not be placed in a publicly accessible directory.

Code
request_slowlog_timeout = 2s
slowlog = /var/log/php-fpm/staging-slow.log

With request_slowlog_trace_depth You specify how deep FPM traces the call stack. Leave the value unchanged for the first test. If callers important for tracing are missing in later traces, a greater depth can provide more context. However, it does not provide additional timing points or a longer observation of the same request.

For the configuration check, php-fpm -t A sample call. Use the binary of the running FPM instance, not the PHP CLI interpreter. If necessary, select the main configuration that is actually in use with -y /pfad/zur/php-fpm.conf; the path is a placeholder that needs to be customized. Then, deploy the verified change via your environment's service management. Only the following HTTP test will verify whether this pool writes a trace.

For the Proof of Functionality Create a temporary PHP endpoint that is accessible only internally and runs on this specific pool. Call it once via HTTP. The following wait statement is designed so that the request exceeds the test threshold during script execution without involving a database or an external service.

Code
<?php
sleep(5);

Note the time of the call and compare it with the FPM message and the entry in the configured slowlog. A corresponding trace should point to the test script and the waiting call. A successful configuration test alone does not prove this: Only the log entry shows that FPM was actually able to capture and write a stack under these conditions.

Next, remove the test endpoint so that it isn't accidentally called again and ties up a worker. This intentional pause does not provide any indication of your application's typical runtime or the pool's capacity. The test checks the path from the HTTP request to the log entry; it is not a benchmark.

From the backtrace to the next measurement

Read the call stack from the innermost call back to its callers. In the native slowlog of PHP 8.4.1, a hypothetical frame might look something like this: execute() name; the trace code writes the function name without the class prefix. Whether the location in your application is PDOStatement::execute() Once you've identified it, you can map it based on the file, line, and application code. Additional frames show the calling functions. This context helps distinguish the relevant path through the application from other calls to the same function.

The topmost frame does not indicate how long PHP has been there. The database operation could have caused the majority of the wait time or may have started only shortly before the trace was captured. A missing index cannot be inferred from this stack trace. Map the trace to the HTTP request based on the timestamp and the log data actually available, rather than assuming that the request URI is in the slowlog.

Next, measure the duration of the specific operation in the application and compare it with the Database Diagnostics If it shows a lock wait time at the same time, check the transactions involved first. If, on the other hand, it points to a costly query, examining the execution plan is the more sensible next step. This comparison helps you avoid hastily rewriting a query whose execution time doesn’t actually explain the slow request.

If, instead, there is an HTTP client call at the top, separate the connection establishment from the wait time for the response in the subsequent measurement, provided the client reports these times. If the connection setup itself takes a long time, the next checkpoint will be at a different point than it would be for a fast connection with a delayed response. The PHP stack alone cannot distinguish between these phases.

If the same call chain appears in multiple similarly slow requests, it's worth instrumenting this section first. Additional information about the pool and processes is explained in the Guide to the PHP-FPM Status Page. Assign these observations to the same time window and pool. However, the frequency in the slowlog does not represent a proportion of time: the log does not contain continuous samples across the entire request. Therefore, use the measured duration to determine whether the observed operation accounts for a significant portion of the delay.

Slowlog, Runtime Measurement, and Timeouts: A Comparison

Choose the tool based on whether you want to find a call site, measure a duration, or limit a request. A Diagnostic threshold It can have the same numerical value as a cutoff limit without having the same effect. If you want to investigate slow requests first, you don't need to configure a cutoff for that purpose, nor do you need to tighten an existing limit just because of the slowlog.

Which tool answers which question about slow PHP requests?
Research QuestionToolBorder
Where was PHP located during the slow request?FPM Slowlog with `request_slowlog_timeout`Snapshot of the call stack; no runtime profile.
From FPM's perspective, how long did the completed request take?FPM access log with the duration field %dReturns a timestamp, but not the call site.
Should FPM terminate a worker that has been running for too long?request_terminate_timeoutIf processing is interrupted, check the post-processing phase separately.
What limits the PHP execution time?max_execution_timeLimits the execution time tracked by PHP; not a flat end-to-end limit.
How long does nginx wait between read operations from the FastCGI backend?fastcgi_read_timeoutLimit the reading break, not the total duration of the response.

The FPM Access Log adds a Runtime Measurement: The "Duration" field lets you compare results after they're complete to see whether similar requests regularly take a long time to run or whether you're investigating an outlier. However, a high value doesn't tell you whether the time was spent in PHP code, a database query, or another operation. For that, you'll need the stack trace or specific measurement points.

Do not treat `max_execution_time` as a blanket timer for the entire HTTP response. You must verify which sleep and I/O wait times PHP counts for the specific build and platform you are using. Do not apply the general rule from the manual to every installation without verification. An empty stack or a long browser time does not, in and of itself, indicate either that the PHP time limit has been exceeded or that there is an error in slowlog logging.

With nginx, too, it depends on what the timer is measuring: If data from the FastCGI backend arrives repeatedly before fastcgi_read_timeout If this occurs between two read operations, the response may take longer overall than the configured value. Conversely, an nginx timeout initially explains the lack of data during that interval, not the point in the PHP code where processing stalled.

Why the Slowlog Remains Empty

First, check the pool actually used. For the affected URL, track which FastCGI socket or address the web server forwards the request to, and verify that the destination matches the pool configuration. Especially when multiple PHP versions or separate pools are running for different websites, the edited file may be valid without having any effect on this particular request.

If the mapping is correct, next check whether the running FPM instance has loaded the change. Check in the service management console to see if the load was successful, and compare the configured file destination with the file you’re monitoring. This way, you’ll avoid mistaking a missing entry for a tracing issue when you’re actually looking at an old log file.

A long response time in the browser is not sufficient evidence that FPM should have captured a backtrace. If the internal test request in the same pool generates a backtrace but the affected page request does not, then the capture is working under the test conditions. In that case, compare the FPM runtime of the affected request with the configured threshold and check the pool utilization, rather than lowering the threshold based solely on the browser response time.

If the entry is also missing during the test, check the FPM error log for messages at the time the test was run. A reference to an unusable log destination will lead you to the configured path, directory, and access permissions. If, on the other hand, FPM reports an access denied Tracing Access via ptrace, the configuration may be valid even though FPM is not allowed to read the worker's PHP call stack.

For a container or a managed hosting service, use the specific error message to determine which diagnostic procedures are available. Do not relax isolation settings across the board just to obtain a trace. If tracing is not permitted in this environment, FPM access logs can help narrow down slow requests, and targeted timings within the application code can help identify the slow operation.

Distinguishing Between Pending Requests and Busy Workers

A page may take a while to respond, even though PHP processes it quickly after it is queued. If all available workers are busy, additional requests may be placed in the queue wait for a free worker. The slowlog is not a measurement tool for this queue. If it remains empty under load, that does not necessarily mean there was sufficient processing capacity available in the pool.

AI-generated illustration of a row of wooden discs in front of several workstations that are already occupied
The AI-generated illustration shows pending requests waiting for workstations that are already in use. The internal FPM status page provides information about such a queue.

Access the internal FPM status page several times during the outage. listen queue Shows the number of currently waiting requests. Compare this value with the number of active and inactive processes: Repeatedly waiting requests with no available workers indicate a bottleneck in the pool. A value of 1 or higher indicates max children reached indicates that the pool has already reached its process limit. For the current issue, the queue and worker utilization observed at the same time are more indicative than this value alone.

Keep the status page internal, since it reveals operational data about the pool. The counter, too, slow requests Needs context: In the PHP 8.4.1 trace path, it is already increased before the slowlog file is opened. Therefore, its increase does not prove that a backtrace was successfully written and can be analyzed. If the status data repeatedly shows queues, check using the PHP-FPM Capacity Planning for Workers, RAM, and Concurrent Requests, whether additional workers would even fit within the memory budget, rather than increasing the process limit simply because of a higher value.

The opposite scenario is a quick response while the worker is still busy. With fastcgi_finish_request() PHP can complete the response and then continue processing, such as by preparing data for a report. From the client's perspective, the request is complete, but the worker is not released back to the pool until after this Rework available again for another inquiry.

In PHP 8.4.1, the phase following `fastcgi_finish_request()` depends on the termination path: The function terminates the FastCGI response and calls the close routine. However, the FPM callback registered there only sets the request to the completion phase when the connection is actually closed. If FastCGI keepalive is enabled, this callback may not be triggered. A successful return alone therefore does not prove a phase change; the slowlog check still requires the execution phase. For follow-up work, do not rely on a blanket promise of logging; instead, measure its duration directly within the application.

`request_terminate_timeout_track_finished` controls the termination timeout even during the post-execution phases described in the manual. It does not change the separate condition of the PHP 8.4.1 slowlog check, which still requires the execution phase. Therefore, even an abort timeout does not guarantee that the follow-up processing will generate a new backtrace.

Selecting the Slowlog Threshold During Operation

Lead the Slowlog Threshold based on observed execution times for comparable requests and your diagnostic goal. The two seconds from the functional test are intended to capture the test call; they are not a production recommendation. If you’re investigating unusually slow calls to an administrative page, first compare its typical FPM execution times with those from the issue. This allows you to select a threshold that can capture suspicious calls without routinely logging normal calls to that page as well.

An interactive page view and a large export often have different typical durations. If they share a pool, only one threshold applies there. A low value may log exports that take a long time as expected; a higher value may miss conspicuous page views. If you need different FPM thresholds, the requests must be routed to separate pools. If the focus is solely on the duration of specific routes or steps, application-side measurements are usually the more direct approach.

Insert one before activation Diagnostic Window Specify a time period, preferably one during which the problem typically occurs. Make a note of which pool, which threshold, and which requests you’re monitoring. This will allow you to later compare slow requests from the access log with the backtraces from the same time period and determine whether you should adjust the threshold or, instead, measure more precisely at a specific point in the code.

Restrict access to the slowlog to only those who need it for troubleshooting. Backtraces may reveal internal file paths and function names; sanitize such information before sharing it. If you no longer need any additional samples after the troubleshooting window, set request_slowlog_timeout at 0 and load the updated pool configuration. This will disable future slowlog logging; the existing file must be handled separately.

Sources and Current State of Knowledge

Status of the research:

Date of research: November 20, 2026.

https://www.php.net/manual/en/install.fpm.configuration.php

https://www.php.net/manual/en/install.fpm.php/

https://nginx.org/en/docs/http/ngx_http_fastcgi_module.html

https://github.com/php/php-src/blob/php-8.4.1/sapi/fpm/fpm/fpm_request.c

https://www.php.net/manual/en/fpm.status.php

https://github.com/php/php-src/blob/php-8.4.1/sapi/fpm/fpm/fpm_main.c

https://github.com/php/php-src/blob/php-8.4.1/sapi/fpm/fpm/fpm_php_trace.c

https://www.php.net/manual/en/function.set-time-limit.php

https://github.com/php/php-src/blob/php-8.4.1/main/fastcgi.c

Current articles

AI-generated illustration of a continuous paper strip with a single offset layer print on one side
Administration

PHP-FPM Slowlog: Investigating Slow Requests Using `request_slowlog_timeout`

PHP-FPM uses `request_slowlog_timeout` to attempt to log the current PHP call stack for slow requests. This threshold does not abort the request. Learn how to set up the slowlog in the correct pool, test it via HTTP, and use the backtrace for targeted follow-up measurements.