nignx 查找php进程,nginx – php-fpm进程监视/分析

在您的php-fpm日志文件中,您应该可以看到如下:

WARNING: [pool www-images] server reached pm.max_children setting (5), consider raising it.

因为活动进程的数量达到极限.您应该能够将其与要进入的请求相关联.

如果没有显示哪个请求导致问题的任何模式,那么您应该将缓慢的日志记录添加到您的php-fpm配置中:

request_slowlog_timeout = 10

slowlog = /var/log/php-fpm/slow.$pool.log

对于占用超过slowlog_timeout限制的每个请求,将记录堆栈跟踪.

如果仍然没有显示任何内容,那么您的内部应用程序日志记录应显示发生减慢的位置.

如果没有足够的细节,那么您可以使用strace作为最后的手段,这将显示正在进行哪些系统调用.这将产生一大堆信息.我建议仅将其附加到单个进程strace -p PID,其中PID是php-fpm实例的processID.

it can also occur with the lowest traffic count of the day.

那肯定会出现在php-fpm缓慢记录中.但是,如果这仅仅显示你的请求是缓慢的,但是不能帮你弄清楚为什么,你可以在你的PHP-FPM配置文件中使用自动预先和后期文件添加调试.

php_value[auto_prepend_file]=/php_shared/prepend.php

php_value[auto_append_file]=/php_shared/postpend.php

还是很简单

您可以设置PHP-FPM状态页面.

将其添加到您的PHP-FPM池配置中:

pm.status_path = /www-status

并通过nginx将请求传递给PHP-FPM

location ~ ^/(www-status)${

include %mysite.root.directory%/conf/fastcgi.conf;

fastcgi_pass unix:%phpfpm.socket%/php-fpm-www.sock;

# or IP address

# fastcgi_pass 127.0.0.1:9000;

#If you're fastcgi.conf doesn't set the query_string

#pass the query string here instead.

# fastcgi_param QUERY_STRING $query_string;

fastcgi_index index.php;

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

allow 127.0.0.1;

allow stats_collector.localdomain;

allow watchdog.localdomain;

deny all;

}

然后去yoursite.com/www-status?full会给你一个大打印出每个php-fpm过程,如:

pool: www

process manager: dynamic

start time: 18/Mar/2013:20:17:21 +1100

start since: 243

accepted conn: 3

listen queue: 0

max listen queue: 0

listen queue len: 0

idle processes: 3

active processes: 1

total processes: 4

max active processes: 1

max children reached: 0

slow requests: 0

************************

pid: 6233

state: Idle

start time: 18/Mar/2013:20:17:21 +1100

start since: 243

requests: 1

request duration: 631

request method: GET

request URI: /www-status

content length: 0

user: -

script: /documents/projects/intahwebz/intahwebz/basereality/www-status

last request cpu: 0.00

last request memory: 262144

btw我打赌一些愚蠢的查询锁定你的数据库.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值