Web php服務器高進程數分析

Web php服務器高進程數分析
 

現象: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調用超時引起
發佈了1 篇原創文章 · 獲贊 2 · 訪問量 9萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章