Apache hanging with MaxClients is reached

6,387

Solution 1

It seems that your server is swapping. Assuming a use of 16 MB for the apache processes, 150 x 16MB = 2400 MB, beyond the capacity of your server (2GB)

Check the memory used by Apache, I think you will need to reduce the MaxClients value.

You can find more information about this in the Hardware and OS Issues section from Apache Performance Tuning

Solution 2

What is your Timeout variable set at?

You may want to push it down if you have not set it:

Timeout 30

As HD has said, you may wish to drop down your MaxClients or increase the RAM to ensure that it is not hitting swap.

Share:
6,387

Related videos on Youtube

Ash White
Author by

Ash White

Updated on September 17, 2022

Comments

  • Ash White
    Ash White almost 2 years

    My Apache 2.2 (preform MPM) is hanging when MaxClients is reached, rather than queueing up requests and serving them when child processes become free. When this happens, the web server is totally unresponsive until it is manually restarted.

    The server stack is Ubuntu 8, MySQL 5, PHP 5. Hardware is Dual Xeons (2.8) with 2GB of RAM. It serves 30,000 - 50,000 pageviews per day. Static images, CSS, and JS are offloaded to a separate server and PHP is cached using eAccelerator. The HTML output of many pages is cached to the filesystem.

    Relevant Apache directives:

    KeepAlive On
    MaxKeepAliveRequests 50
    KeepAliveTimeout 2
    StartServers          2
    MaxClients          150
    MinSpareThreads      25
    MaxSpareThreads      75
    ThreadsPerChild      25
    MaxRequestsPerChild   2000
    

    • Rodrigo Sieiro
      Rodrigo Sieiro about 14 years
      Ash, I was having the same problem as you and I found the solution. Check it out here, maybe it could also help you.
  • Ash White
    Ash White almost 15 years
    I forgot to address that... each process is actually averaging around 10MB, so 150*10 = 1500MB. Even if these numbers spike and the server does start swapping, would the lack of free memory cause Apache to hang like it is? That seems like a strange cause-and-effect.
  • hdanniel
    hdanniel almost 15 years
    Yes, if Apache is swapping, then the server will stop to answer. Is really really painful. Also remember that the OS needs memory for other processes besides Apache.
  • Ash White
    Ash White almost 15 years
    I thought I had it fixed when I upped the RAM to 6GB, but Apache is still becoming unresponsive when MaxClients is reached, no matter how much RAM is free. Any other ideas?