php-fpm timeout setting request_terminate_timeout analysis

I found the problem of returning 500 and 502 after a php configuration was found. Today, I saw a brother wrote it very well, record it.
 
There is a timeout log in the php log, but my request_terminate_timeout is set to 0. In theory, there should be no timeout period.
 
PHP Fatal error:  Maximum execution time of 30 seconds exceeded in ...
 
OK, first list the current configuration:
 
php-fpm:
request_terminate_timeout = 0
php.ini:
max_execution_time = 30
 
First check the comments on request_terminate_timeout in the php-fpm file
 
; The timeout for serving a single request after which the worker process will
; be killed. This option should be used when the 'max_execution_time' ini option
; does not stop script execution for some reason. A value of '0' means 'off'.
; Available units: s(econds)(default), m(inutes), h(ours), or d(ays)
; Default Value: 0
 
 
This comment explains that request_terminate_timeout is suitable for killing the php-fpm request when max_execution_time cannot terminate the script for some reason.
Also look at the comments for max_execution_time: this sets the maximum execution time allowed before the script is aborted by the parser, the default is 30s. It seems that my request should be killed by the setting of max_execution_time.
 
Well, don't give up, do an experiment:
 
php-fpm request_terminate_timeout 设置 0 15
php.ini max_execution_time setting 30 30
Results of the php has Fatal error timeout log, http status code is 500 There is no Fatal error timeout log in php, the http status code is 502, and the php-fpm log contains the kill subprocess log
 
Well, the conclusion is that the php execution time of the web request is controlled by two aspects, one is the max_execution_time of php.ini (it should be noted that sleep, the time waiting for the response of the http request is not counted, here is the real execution time), The other is the php-fpm request_terminate_timeout setting, which counts n seconds from the start of the request.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326169256&siteId=291194637