Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.
<IfModule mpm_prefork_module>
    StartServers            150
    MinSpareServers         5
    MaxSpareServers         20
    ServerLimit             200
    MaxClients              200
    MaxRequestsPerChild     0
</IfModule>

top after apache stop responding:

After few hours of running my server stops responding due to too many apache processses in sleeping... And only thing I can do is to restart apache

What can I do? I am on debian 6 with LAMP
KeepAlive is off for the moment.

share|improve this question
4  
The 317 processes listed in top include all processes, not just Apache processes. –  Shane Madden Sep 8 '11 at 16:52
    
What are your keepalive settings, your sleeping processes could be waiting for connections if they are set very high... –  Sean Kimball Sep 8 '11 at 17:03
    
Off............... –  dynamic Sep 8 '11 at 17:11
    
@Shane: i doubt I have 100 other process –  dynamic Sep 8 '11 at 17:15
2  
Sure you do, or at least close to it. Stop Apache and see for yourself. Anyway, if your problem is that Apache is becoming unresponsive, you should probably be giving some details about that; what kind of response do page requests get? Anything in Apache's error logs? –  Shane Madden Sep 8 '11 at 17:23

3 Answers 3

up vote 2 down vote accepted

First you should figure out how much RAM each Apache process uses on average. Run ps -ylC apache2 --sort:rss to get a rough estimate -- total up the RAM and divide by the number of processes. You might want to exclude any values that are wildly different.

Then take a look at the total RAM usage, and subtract the Apache usage.

MaxClients should be set to roughly: ((total RAM) - (RAM used by processes other than Apache) - (some cushion)) / (average RAM used by Apache processes)

EDIT: Also you may want to look at the output of mod_status to see if there are a lot of processes in the KeepAlive state ("K"). If so you need to reduce your KeepAliveTimeout setting.

share|improve this answer
    
the RSS entries are about 14000. I have 4GB ram –  dynamic Sep 8 '11 at 17:13
    
KeepAlive is off –  dynamic Sep 8 '11 at 17:13
1  
Any reason why KeepAlive is off? Have you tried turning it on? –  xofer Sep 8 '11 at 17:17
    
to simplify the debug, it has been always on, with a timeout of 2-3sec. So keepalive isn't the problem. Which values of maxclients and serverlimit do you suggest me? –  dynamic Sep 8 '11 at 17:23
    
How many apache2 processes are there? –  xofer Sep 8 '11 at 17:25
  1. Enable mod_status. Read that page for details and security considerations.
  2. View the server status at http://example.org/server-status?refresh=N (Refresh every N seconds) . You will see each httpd child, the page it is serving, the IP of the client which requested the page, etc.

Things to look for:

  • Usually when Apache has too many children, it's because one page or a set of related pages are hanging due to code issues. Look for httpd children which are all serving the same page. That page may be buggy.
  • If one client is hammering your server by requesting multiple pages in quick succession, you can see it on this page.
  • Sometimes you can also detect a DDOS on this page. Look for multiple IPs all requesting the same buggy page, or requesting multiple slow pages. DDOSes are hard to detect, due to their nature.
share|improve this answer

First doublecheck if you actually do have 300 apache processes with something like pgrep -c apache2.

It is possible you changed the config but haven't restarted yet (this can easily stretch into many weeks).

If your server stops responding, is it only the apache server, or the entire system? Try to monitor your memory usage (the memory-free metric is far easier to measure than the total usage by all processes).

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.