首页 > 故障排查 > 正文

Web php服务器高进程数分析
2012-06-13 16:41:23   来源:我爱运维网   评论:0 点击:

现象:1台WEB应用的PHP服务器间歇性高进程数,ZABBIX监控到的进程数趋势如下:分析过程:1. 通过开启php-fpm的slow log得到请求slow次数...
现象:1台WEB应用的PHP服务器间歇性高进程数,ZABBIX监控到的进程数趋势如下:

Web php服务器高进程数分析1
 

分析过程:
1.       通过开启php-fpm的slow log得到请求slow次数统计
[root@5iops-php php]# cat /home/logs/php/php-fpm-slow.log |grep 'pool www' | awk -F: '{ print $1":"$2 }' | sort | uniq –c
在21:55,22:08,22:15,23:23, 00:44 几个时间点上符合High php process的趋势。
Web php服务器高进程数分析2
2.       Slow log显示slow均发生在/home/5iops/php/includes/phprpc/phprpc_client.php:第399行
[13-Jun-2012 00:01:06] [pool www] pid 3803
script_filename = /home/5iops/web/clientweb/application/index.php
[0x000000001fd5f1c8] fgets() /home/5iops/php/includes/phprpc/phprpc_client.php:399
[0x000000001fd5eff0] _post() /home/5iops/php/includes/phprpc/phprpc_client.php:270
[0x000000001fd5ee58] invoke() /home/5iops/webroot/clientweb/v1.5.4/application/utils/orm/driver/phprpc/client.php:33
[0x00007fff19a04f20] __call() unknown:0
 
3.       查看源码发现为:PHPRPC Client 3.0调用
        $request =
            "POST $url HTTP/{$this->_http_version}\r\n" .
            "Host: {$this->_server['host']}:{$this->_server['port']}\r\n" .
            "User-Agent: PHPRPC Client 3.0 for PHP\r\n" .
            $auth .
            $connection .
            $cookie .
            $request_id .
            "Accept: */*\r\n" .
            "Accept-Encoding: gzip,deflate\r\n" .
            "Content-Type: application/x-www-form-urlencoded; charset={$this->_charset}\r\n" .
            "Content-Length: {$content_len}\r\n" .
            "\r\n" .
            $request_body;
        fputs($this->_socket, $request, strlen($request));
        while (!feof($this->_socket)) {
            $header = array();
            $line = fgets($this->_socket);   -- 第399
                        if (empty($line)) continue;
            if (preg_match('/HTTP\/(\d\.\d)\s+(\d+)([^(\r|\n)]*)(\r\n|$)/i', $line, $match)) {
                $this->_http_version = $match[1];
                $status = (int)$match[2];
                $status_message = trim($match[3]);
                if ($status != 100 && $status != 200) {
                    $this->_disconnect();
                    return new PHPRPC_Error($status, $status_message);
                }
            }

结论:
         后端PHPRPC Client 3.0调用超时引起
 

相关热词搜索:Web php 服务器

上一篇:Squid无法启动的故障排查
下一篇:轻松应对IDC机房带宽突然暴涨问题

分享到: 收藏
评论排行