使用apache benchmark(ab) 測試報錯彙總

一、socket: Too many open files (24)

解決方法:html

[root@zabbix ~]# ulimit -a
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 14802
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) 819200
real-time priority              (-r) 0
stack size              (kbytes, -s) 10240
cpu time               (seconds, -t) unlimited
max user processes              (-u) 14802
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
調整能夠打開的文件數
[root@zabbix ~]# ulimit -n 65535

二、http錯誤日誌報錯

server reached MaxClients setting,consider raising the Max Clients setting」git

設置以下:web

/etc/httpd/conf/httpd.conf

## Server-Pool Size Regulation (MPM specific)

## 

# prefork MPM

# StartServers: number of server processes to start

# MinSpareServers: minimum number of server processes which are kept spare

# MaxSpareServers: maximum number of server processes which are kept spare

# ServerLimit: maximum value for MaxClients for the lifetime of the server

# MaxClients: maximum number of server processes allowed to start

# MaxRequestsPerChild: maximum number of requests a server process serves

<IfModule prefork.c>

StartServers       10

MinSpareServers    10

MaxSpareServers   75

ServerLimit      2000

MaxClients       2000

MaxRequestsPerChild  4000

</IfModule>

 

# worker MPM

# StartServers: initial number of server processes to start

# MaxClients: maximum number of simultaneous client connections

# MinSpareThreads: minimum number of worker threads which are kept spare

# MaxSpareThreads: maximum number of worker threads which are kept spare

# ThreadsPerChild: constant number of worker threads in each server process

# MaxRequestsPerChild: maximum number of requests a server process serves

<IfModule worker.c>

StartServers         4

MaxClients         2000

MinSpareThreads     25

MaxSpareThreads     75 

ThreadsPerChild     25

MaxRequestsPerChild  0

</IfModule>

 三、: apr_socket_recv: Connection reset by peer (104) 

改服務端apachemaxclients參數,調大最大打開文件數,都不解決問題,最後才發現是由於ab的源碼對ab的併發有限制,修改源碼從新編譯apache:apache

Apache源碼下載地址:http://httpd.apache.org/download centos

我下的是 2.2 服務器

修改源碼support目錄下的ab.c文件,大概在1369,修改成:併發

 /* catch legitimate fatal apr_socket_recv errors */
        else if (status != APR_SUCCESS) {
            err_recv++;
            if (recverrok) {
                bad++;
                close_connection(c);
                if (verbosity >= 1) {
                    char buf[120];
                    fprintf(stderr,"%s: %s (%d)\n", "apr_socket_recv", apr_strerror(status, buf, sizeof buf), status);
                }
                return;
            } else {
               // apr_err("apr_socket_recv", status);
               bad++;
               close_connection(c);
               return;      // 到這裏 
            }
        }

修改後編譯,注意添加 config 執行權限。socket

我是把編譯後的ab可執行文件拷貝過來,避免重裝apache。建一個目錄執行便可。ide

四、 其餘參考性能

apache的源碼安裝詳細過程全紀錄http://www.jb51.net/article/59474.htm

apr_socket_recv: Connection reset by peer 錯誤(安裝參考,並無解決問題)http://blog.csdn.net/kimsung/article/details/9422991

Ab測試說明博文 http://blog.csdn.net/gzh0222/article/details/7172341

網站服務器壓力Web性能測試:Apache Bench,Webbench,http_load安裝使用 http://www.freehao123.com/apache-bench-webbench/

Apache下載地址: http://apache.fayea.com/

卸載centos默認的apache:  http://blog.sina.com.cn/s/blog_701300bc0100nzea.html

相關文章
相關標籤/搜索