您好,欢迎访问一九零五行业门户网

善用php-fpm的慢执行日志slow log分析PHP执行效率和程序BUG

启用 php-fpm 的 slow log 日志 ,查看 执行 时间过长的php文件,并将 执行 时间过长的进程直接终止掉!看看效果如何! 具体操作方法也简单,就修改一个文件, 执行 命令:# vi /usr/local/php/etc/php-fpm.conf php 5.3.3 之前版本设置如下: the timeout (
启用 php-fpm 的 slow log 日志,查看执行时间过长的php文件,并将执行时间过长的进程直接终止掉!看看效果如何!
具体操作方法也简单,就修改一个文件,执行命令:# vi /usr/local/php/etc/php-fpm.conf
php 5.3.3 之前版本设置如下:
      the timeout (in seconds) for serving a single request after which the worker process will be terminated      should be used when 'max_execution_time' ini option does not stop script execution for some reason      '0s' means 'off'      10s      the timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file      '0s' means 'off'      1s      the log file for slow requests      logs/slow.log
php 5.3.3 之后版本设置如下:
; the timeout for serving a single request after which a php backtrace will be; dumped to the 'slowlog' file. a value of '0s' means 'off'.; available units: s(econds)(default), m(inutes), h(ours), or d(ays); default value: 0request_slowlog_timeout = 1s  (对执行时间超过1s的php脚本进行日志记录); the log file for slow requests; default value: /usr/local/php/var/log/php-fpm.log.slowslowlog = /usr/local/php/var/log/php-fpm.log.slow (开启慢执行日志,日志目录路径一定要正确存在,否则会报错); 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: 0request_terminate_timeout = 30s (当php脚本执行时间超过30秒后终止该php脚本)
注:request_terminate_timeout 将执行时间太长的进程直接终止
request_slowlog_timeout 将执行过慢的文件写入日志
以后即可根据慢执行日志 /usr/local/php/var/log/slow.log 来优化程序文件了!
其它类似信息

推荐信息