为什么Webmin/Virtualmin的apache总有MaxClients和ServerLimit错误
  • 几乎没有什么流量的网站,Webmin/Virtualmin的apache日志里面也有MaxClients和ServerLimit错误,这是怎么回事?为什么Virtualmin/Webmin的apache的httpd日志总有MaxClients和ServerLimit错误?

    tail -f /www.654z.com/log/httpd/error_log

    WARNING: MaxClients of 256 exceeds ServerLimit value of 10 servers,
     lowering MaxClients to 10.  To increase, please see the ServerLimit
     directive.

    流量稍微大一点,就会有这个错误:

    tail -f /www.654z.com/log/httpd/error_log

     [error] server reached MaxClients setting, consider raising the MaxClients setting

    神奇了,apache性能如此之差吗?不可能! 肯定有原因。

    经过仔细分析,httpd.conf 调用了 conf.d/*.conf 所有文件,会不会问题在这里?
    [root@654z.com~]# grep ServerLimit /etc/httpd/conf.d/*
    /etc/httpd/conf.d/swtune.conf:# ServerLimit: maximum value for MaxClients for the lifetime of the server
    /etc/httpd/conf.d/swtune.conf:ServerLimit       10

    果然,我们发现了 /etc/httpd/conf.d/swtune.conf 这个文件。

    [root@www.654z.com ~]# more /etc/httpd/conf.d/swtune.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       1
    MinSpareServers    1
    MaxSpareServers    5
    ServerLimit       10   太XX了
    MaxClients        10   太XX了
    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       1
    MaxClients        10
    MinSpareThreads    1
    MaxSpareThreads    4
    ThreadsPerChild     25
    MaxRequestsPerChild  0
    </IfModule>

    真相大白,解决办法:

    mv /etc/httpd/conf.d/swtune.conf /etc/httpd/conf.d/swtune.654z

    然后重启apache,搞定!

     

  • 点这里复制本页地址发送给您QQ/MSN上的好友
  • 300*300广告