zoukankan      html  css  js  c++  java
  • php.ini配置max_execution_time和FPM配置request_terminate_timeout

    PHP限定脚本执行时长的方式有几种,下面说下php.ini中的max_execution_time和php-fpm.conf中的request_terminate_timeout

    1. php.ini中的max_execution_time

    ; Maximum execution time of each script, in seconds
    ; http://php.net/max-execution-time
    ; Note: This directive is hardcoded to 0 for the CLI SAPI
    max_execution_time = 1

    上面是php.ini配置文件中的max_execution_time及其说明,上面说了,这个值限定了脚本的最大执行时间(单位是秒)

    set_time_limit()函数和配置指令max_execution_time只影响脚本本身执行的时间。任何发生在诸如使用system()的系统调用,流操作,数据库操作等的脚本执行的最大时间不包括其中,当该脚本已运行。在测量时间是实值的Windows中,情况就不是如此了。

    2. php-fpm.conf中的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 = 0
    request_terminate_timeout = 4s
    设置单个请求的超时中止时间。该选项可能会对 php.ini 设置中的 max_execution_time 因为某些特殊原因没有中止运行的脚本有用。设置为 ‘0’ 表示 ‘Off’。可用单位:s(秒),m(分),h(小时)或者 d(天)。默认单位:s(秒)。默认值:0(关闭)。

     通过上面两个说明及实验验证得出结论,max_execution_time=1,不一定1s后就会中止脚本,可能是2s、3s甚至更长的时间;而request_terminate_timeout=4则就会在4s后中止脚本的执行。所以在配置超时时间的时候,最好两个都配置,max_execution_time时间短一点,而request_terminate_timeout时间长一点

    本文转自:http://blog.csdn.net/lipengfeihb/article/details/55212567

  • 相关阅读:
    file is universal (3 slices) but does not contain a(n) armv7s slice error for static libraries on iOS
    WebImageButton does not change images after being enabled in Javascript
    ajax OPTION
    编程遍历页面上所有TextBox控件并给它赋值为string.Empty?
    获取海洋天气预报
    C#线程系列教程(1):BeginInvoke和EndInvoke方法
    js控制只能输入数字和小数点
    Response.AddHeader(,)
    ManualResetEvent的理解
    Convert.ToInt32、int.Parse(Int32.Parse)、int.TryParse、(int) 区别
  • 原文地址:https://www.cnblogs.com/liuzhongchao/p/8565756.html
Copyright © 2011-2022 走看看