Apache Prefork MaxClients cannot exceed 256

9,215

I've solved the problem.

The problem : ServerLimit and MaxClients values higher than 256 do not take effect, they stay in 256. Each time I change things in httpd.conf and then I restart apache using the command :

# httpd restart

Nothing really changed.

The solution : Be sure that httpd completely stops then start again. The command that worked for me instead of the one above :

#httpd stop
#httpd start

It looks like all apache server instances should be stopped in order to take in account the new limits set for MPM.

Thanks for your replies and correct me if I'm wrong.

Share:
9,215

Related videos on Youtube

ARMBouhali
Author by

ARMBouhali

Updated on September 18, 2022

Comments

  • ARMBouhali
    ARMBouhali almost 2 years

    I manage a Centos 6.6 server (with cpanel expired license / maybe it's not important) with 8 cores and 64GB RAM and my HTTP server becomes very slow when it reaches between 250 and 300 simultaneous connections.

    When I found about mpm prefork configuration as a solution to increase server performance I've looked for the parameters within the httpd.conf file and all its includes, but nothing was there. It looks like my apache uses default mpm parameters.

    So I've tried to add a new configuration and noticed some changes in maximum number of clients via my mod_status web page. When I put values for ServerLimit and MaxClients less than 256, server-status display changes, but when I try a value larger than 256, it simply stops at 256.

    Here's a concise version of the server-status page, with MaxClients and ServerLimit set to 257, it however displays exactly 256 slots in 4 lines of 64 workers. copmare with http://apache.org/server-status

    Server Version: Apache/2.4.10 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4
    Server MPM: prefork
    Server Built: Jan 23 2015 21:04:30
    
    --------------------------------------------------------------------
    Current Time: Thursday, 12-Feb-2015 19:15:49 CET
    Restart Time: Thursday, 12-Feb-2015 19:13:41 CET
    Parent Server Config. Generation: 266
    Parent Server MPM Generation: 265
    Server uptime: 2 minutes 8 seconds
    Server load: 0.76 0.66 0.63
    Total accesses: 7771 - Total Traffic: 296.0 MB
    CPU Usage: u3.76 s.62 cu77.6 cs7.05 - 69.6% CPU load
    60.7 requests/sec - 2.3 MB/second - 39.0 kB/request
    256 requests currently being processed, 0 idle workers
    
    WWWWWKWKWKWWRRWWWKKWKKWWWKKWWWCKKKWWWWWKKWCWWWWWKKCWWKKWKCWKRCWW
    WWWKKKKKWKWKWWWCWWKKWWRWKKRWWCWKWWWWKKKKKKWKCKWKKKKKWCWKCWWWKWRW
    KWKKCKKKWKWKWWKLWWWKWWKCCCWKWWKKKKKWKWWKWWKKKWKWWCCRKKCCWKKWKWCW
    CWKKRKKWWKRKKWWWWKWWWKWWKKWKKKWWWKWWWKLKWWKWWKKKKWWWKWWKRKWKWCWW
    

    How can I solve this problem ? Actually I need to tune prefork parameters in order to serve 10000 clients at the same time. Using NGINX to serve static files is not possible for me.

    I also want to have more information about MPM configuration during runtime.

    Any clues ?


    Edit : Here is the segment of mpm configuration I've added

    <IfModule prefork.c>
        Mutex default mpm-accept
    
    # BEGIN : CUSTOM CONFIGURATION - all the following code is added by me
    #    StartServers         6
    #    MinSpareServers      6
    #    MaxSpareServers     12
    
    ## Whatever the value (> 256) I enter for those two parameters, it doesn't exceed 256 in runtime (as shown in server-status page)
        ServerLimit        512 
        MaxClients         512
    # END : CUSTOM CONFIGURATION
    </IfModule>
    

    With the two uncommented parameters above, I couldn't figure how to have the 256 limit increased. Is there something missing ?

    • faker
      faker over 9 years
      You'll need to post the full configuration. MaxClients is just the maximum, but you have idle workers, so why would it spawn more than it needs to?
  • ARMBouhali
    ARMBouhali over 9 years
    I've edited the post and added my configuration. By the way, the link in your answer was my start point to configure the server. The problem is that it's not working as needed when I exceed 256 value of ServerLimit and MaxClients
  • YuKYuK
    YuKYuK over 9 years
    you reload or restart apache after change ? Do you know if you can run under worker mpm and not prefork ?
  • ARMBouhali
    ARMBouhali over 9 years
    Of course I restart after every change. for Worker MPM I'm using mod_php which is not thread-safe, so I can't actually take risks to recompile some apache parts and configure it for suPHP for example. Isn't there any relation between the mpm parameters themselves (like a limit of maxclients per startservers) ?