I have set request_terminate_timeout
directive in PHP-FPM pool configuration file which is currently 100s
and I'm setting set_time_limit(600)
for an individual PHP file. But the issue is that the lowest triggers first so 600s
never applies which I don't expect.
Is it possible to retain request_terminate_timeout
globally while setting a higher value for maximum execution time in individual PHP files?
I have fronted a similar problem before. Not completely sure it can fit with your problem, but I have tried to document everything just to be sure to give "safe" hints.
The brutal answer to your question I guess it's NO, because the directives you specify in php-fpm.conf
are mostly not changeable from ini_set()
, and set_time_limit
is a almost nothing more than a convenience wrapper on ini_set()
.
The set_time_limit
should only "overwrite" the max_execution_time
directive, because
they only affect the execution time of the script itself
(there is a specific note in the official documentation).
On the other hand, request_terminate_timeout
is related to FPM, so we are talking about the process management level here:
should be used when the 'max_execution_time' ini option does not stop script execution for some reason.
So, to try answering the question, I think the problem is that you are trying to mix something handled by FPM (request_terminate_timeout
) and something handled by PHP itself (max_execution_time
).
Using max_execution_time in place of request_terminate_timeout (but using it to the real, maximum upper-bound), should solve the problem.
The max_execution_time
description in the official documentation has an hint about this common problem, that is:
Your web server can have other timeout configurations that may also interrupt PHP execution. Apache has a Timeout directive and IIS has a CGI timeout function. Both default to 300 seconds. See your web server documentation for specific details.
Note: Some variables in this equation can be even webserver-dependent (example: read timeout).