启用 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' <value name="<span><strong>request_terminate_timeout</strong></span>"><span><strong>10s</strong></span></value> The timeout (in seconds) for serving of single request after which a php backtrace will be dumped to slow.log file '0s' means 'off' <value name="<span><strong>request_slowlog_timeout</strong></span>"><span><strong>1s</strong></span></value> The log file for slow requests <value name="slowlog">logs/slow.log</value>
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: 0 request_slowlog_timeout = 1s (对<strong><strong>执行</strong></strong>时间超过1s的php脚本进行<strong>日志</strong>记录) ; The log file for slow requests ; Default Value: /usr/local/php/var/log/php-fpm.log.slow slowlog = /usr/local/php/var/log/php-fpm.log.slow (开启慢<strong><strong>执行</strong></strong><strong>日志</strong>,<strong>日志</strong>目录路径一定要正确存在,否则会报错) ; 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 = 30s (当php脚本<strong><strong>执行</strong></strong>时间超过30秒后终止该php脚本)
注:request_terminate_timeout 将执行时间太长的进程直接终止
request_slowlog_timeout 将执行过慢的文件写入日志
以后即可根据慢执行日志 /usr/local/php/var/log/slow.log 来优化程序文件了!

熱AI工具

Undresser.AI Undress
人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover
用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool
免費脫衣圖片

Clothoff.io
AI脫衣器

AI Hentai Generator
免費產生 AI 無盡。

熱門文章

熱工具

mPDF
mPDF是一個PHP庫,可以從UTF-8編碼的HTML產生PDF檔案。原作者Ian Back編寫mPDF以從他的網站上「即時」輸出PDF文件,並處理不同的語言。與原始腳本如HTML2FPDF相比,它的速度較慢,並且在使用Unicode字體時產生的檔案較大,但支援CSS樣式等,並進行了大量增強。支援幾乎所有語言,包括RTL(阿拉伯語和希伯來語)和CJK(中日韓)。支援嵌套的區塊級元素(如P、DIV),

SublimeText3 英文版
推薦:為Win版本,支援程式碼提示!

SublimeText3漢化版
中文版,非常好用

Dreamweaver Mac版
視覺化網頁開發工具

VSCode Windows 64位元 下載
微軟推出的免費、功能強大的一款IDE編輯器