php-fpm超时时间设置request_terminate_timeout分析
2017-11-22 16:17
981 查看
今天发现了一个很神奇的事情,php日志中有一条超时的日志,但是我request_terminate_timeout中设置的是0,理论上应该没有超时时间才对。
PHP Fatal error: Maximum execution time of 30 seconds exceeded in ...
OK,先列出现在的配置:
php-fpm:
request_terminate_timeout = 0
php.ini:
max_execution_time = 30
先查阅了一下php-fpm文件中关于request_terminate_timeout的注释
; 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
这个注释说明了,request_terminate_timeout 适用于,当max_execution_time由于某种原因无法终止脚本的时候,会把这个php-fpm请求干掉。
再看看max_execution_time的注释:这设置了脚本被解析器中止之前允许的最大执行时间,默认是30s。看样子,我这个请求应该是被max_execution_time这个设置干掉了。
好吧,不死心,做了一个实验:
好吧,结论是web请求php执行时间受到2方面控制,一个是php.ini的max_execution_time(要注意的是sleep,http请求等待响应的时间是不算的,这里算的是真正的执行时间),另一个是php-fpm request_terminate_timeout 设置,这个算的是请求开始n秒。
PHP Fatal error: Maximum execution time of 30 seconds exceeded in ...
OK,先列出现在的配置:
php-fpm:
request_terminate_timeout = 0
php.ini:
max_execution_time = 30
先查阅了一下php-fpm文件中关于request_terminate_timeout的注释
; 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
这个注释说明了,request_terminate_timeout 适用于,当max_execution_time由于某种原因无法终止脚本的时候,会把这个php-fpm请求干掉。
再看看max_execution_time的注释:这设置了脚本被解析器中止之前允许的最大执行时间,默认是30s。看样子,我这个请求应该是被max_execution_time这个设置干掉了。
好吧,不死心,做了一个实验:
php-fpm request_terminate_timeout 设置 | 0 | 15 |
php.ini max_execution_time 设置 | 30 | 30 |
执行结果 | php有Fatal error超时日志,http状态码为500 | php无Fatal error超时日志,http状态码为502,php-fpm日志中有杀掉子进程日志 |
相关文章推荐
- 给XMLHttpRequest设置超时时间
- 一个严格的PHP Session会话超时时间设置方法
- php-fpm通过request_slowlog_timeout检查哪个脚本执行时间长
- php脚本超时时间设置
- 设置PHP脚本执行超时的时间
- php-fpm通过request_slowlog_timeout检查哪个脚本执行时间长
- Volley框架 以及 设置request超时时间
- 设置php下载文件的超时时间
- php设置页面超时时间解决方法
- php脚本超时时间设置
- php.ini配置max_execution_time和FPM配置request_terminate_timeout
- php脚本超时时间设置
- PHP请求远程地址设置超时时间
- php-fpm.conf 重要参数 max_children 和 request_terminate_timeout
- php下载文件超时时间的设置方法
- 一个严格的PHP Session会话超时时间设置方法
- Volley框架 以及 设置request超时时间
- PHP请求远程地址设置超时时间
- 【开源项目13】Volley框架 以及 设置request超时时间
- php-fpm.conf重要参数max_children和request_terminate_timeout