Home>Article>Backend Development> Understanding of PHP-FPM parameters

Understanding of PHP-FPM parameters

王林
王林 forward
2019-08-21 10:01:33 1665browse

process_control_timeout

English explanation

process_control_timeout mixedTime limit for child processes to wait for a reaction on signals from master. Available units: s(econds), m(inutes), h(ours), or d(ays) Default Unit: seconds. Default value: 0.

Chinese explanation

process_control_timeout mixed 设置子进程接受主进程复用信号的超时时间。可用单位:s(秒),m(分),h(小时)或者 d(天)。默认单位:s(秒)。默认值:0(关闭)。

There is something inappropriate in the Chinese translation. The English explanation does not specify this The signal is a multiplexed signal.

My understanding:

Processing requests

In principle,php-fpmwill choose the idlefastcgiprocess to process Before processing the request, php-fpm will send a signal to fastcgi to prepare the fastcgi process to accept the request processing. However, the fastcgi process is not always able to handle the request, that is, it cannot always respond to the signal (such as suspended animation). At this time, you need to set the time php-fpm leaves for the fastcgi process to respond to the signal. If it times out, php -fpm will think of other ways (such as selecting otherfastcgiprocesses), this is the role of theprocess_control_timeoutparameter.

php-fpmPerformreload

process_control_timeout= 10


      

When the browser accesseshttp://localhost, performphp-fpmsmoothingreload, after the fastcgi signal receives the shutdown process signal, the first sleep function will return directly, but The second sleep is still executing. Therefore, php-fpm will be stuck by this old fastcgi process for 10 seconds. After that, a smooth restart can be completed.

request_terminate_timeout

Inphp-fpm.confThe description in the file is as follows:

; 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

The translation is:
request_terminate_timeoutThe parameter sets the timeout for processing a single request. After that, the worker process will be killed. Lose. This option should be used if themax_execution_timeoption in the php.ini file does not stop the script from running for some reason. The default value is 0, which means this option is turned off.

As mentioned above,request_terminate_timeoutsets the timeout of the request, andmax_execution_timein the php.ini configuration. According to the following explanation in the manual, the script is Maximum execution time allowed.

max_execution_time integer 这设置了脚本被解析器中止之前允许的最大执行时间,单位秒。 这有助于防止写得不好的脚本占尽服务器资源。 默认设置为 30。 从命令行运行 PHP 时,默认设置为 0。 最大执行时间不会影响系统调用和系统操作等。更多细节参见 set_time_limit()。 在 安全模式 下你不能通过 ini_set() 来修改此设置。 唯一的解决方法是关闭安全模式或者在 php.ini中修改时间限制。 你的 web 服务器也可以有其他超时设置,也有可能中断 PHP 的执行。 Apache 有一个 Timeout 指令,IIS 有一个 CGI 超时功能。 他们默认都是 300 秒。更多具体信息参见你的 web 服务器的文档。

The difference is as follows:

After timeout,request_terminate_timeoutwill return 502Bad Gateway, andmax_execution_timewill throwFatalError.

max_execution_time does not include the time for system calls such as usingsystem(),sleep(), stream operations, database operations, etc., so it is relatively useless, while request_terminate_timeout will Contains the complete request time of the program.

In addition, turning on request_terminate_timeout will not invalidate max_execution_time. Whoever reaches the timeout first will take effect.

For more related PHP issues, please visit the PHP Chinese website://m.sbmmt.com/

The above is the detailed content of Understanding of PHP-FPM parameters. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:PHPStudy. If there is any infringement, please contact admin@php.cn delete