解决php-fpm占用cpu memory过高,开启php-fpm request_slowlog_timeout
项目刚从win下挪到linux下,发现cpu过高,内存也占用较多,以下是我解决问题的过程:
首先更改php-fpm配置
vim /usr/local/php/etc/php-fpm.conf
找到
request_slowlog_timeout
slowlog
开启他们,request_slowlog_timeout是设置超时时间,slowlog是记录路径
我的配置:
slowlog = /home/wwwlog/php-fpm-slowlog_timeout.log ; 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 = 5
如果正确开启后日志将开始记录,就可以找到问题在哪并解决
#重启php-fpm
killall php-fpm /usr/local/php/sbin/php-fpm &
查看日志
tailf /home/wwwlog/php-fpm-slowlog_timeout.log