• 使用apache benchmark(ab) 测试报错汇总


    1、socket: Too many open files (24)

    解决方法:

    [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

    2、http错误日志报错

    server reached MaxClients setting,consider raising the Max Clients setting”

    设置如下:

    /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>

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

    改服务端apachemaxclients参数,调大最大打开文件数,都不解决问题,最后才发现是因为ab的源码对ab的并发有限制,修改源码重新编译apache:

    Apache源码下载地址:http://httpd.apache.org/download 

    我下的是 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)
    ", "apr_socket_recv", apr_strerror(status, buf, sizeof buf), status);
                    }
                    return;
                } else {
                   // apr_err("apr_socket_recv", status);
                   bad++;
                   close_connection(c);
                   return;      // 到这里 
                }
            }

    修改后编译,注意添加 config 执行权限。

    我是把编译后的ab可执行文件拷贝过来,避免重装apache。建一个目录执行即可。

    4、其他参考

    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

  • 相关阅读:
    ABP
    妖道角
    检测空值,以及会不会出现mapping类型不一致的问题
    wcf服务契约代理链
    wcf服务契约继承
    win64+anaconda+xgboost(转)
    python中迭代问题
    ROC曲线和AUC值(转)
    python中split()和split(' ')的区别
    str和repr的区别(转)
  • 原文地址:https://www.cnblogs.com/wuling129/p/4792778.html
Copyright © 2020-2023  润新知