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.

Here are my MPM constraints:

<IfModule mpm_prefork_module>
    StartServers         10
    MinSpareServers      10
    MaxSpareServers      10
    MaxClients           10
    MaxRequestsPerChild  2000
</IfModule>

However despite this, I have over 20 apache processes running currently, and in the past hour or two there have been as many as 40-50. Shouldn't the MaxClient and MaxSpareServers keep the number of processes under control (i.e. about 10)?

Is there something I'm missing?

share|improve this question
    
Two questions: Are you changing the correct config file? Did you restart apache after this change? –  Khaled Dec 22 '10 at 7:28
    
Yes. I'm changing apache2.conf, theres nothing in my httpd.conf. And yes, i restarted. –  Josh Nankin Dec 22 '10 at 15:36

2 Answers 2

Apache comes in different flavours, two of the most common being prefork and worker. The prefork model spawns several processes but each process handles only one request at a time. The worker model, on the other hand, spawns several processes and each process has multiple threads, each thread handling one request at a time.

Depending on your distribution you may be running a different model to that which you are expecting. You are expecting prefork but are you sure this is the type that is running? To find out type:

$ httpd -V
Server version: Apache/2.2.15 (Unix)
Server built:   May 28 2010 07:58:25
Server's Module Magic Number: 20051115:24
Server loaded:  APR 1.4.2, APR-Util 1.3.9
Compiled using: APR 1.4.2, APR-Util 1.3.9
Architecture:   32-bit
Server MPM:     Prefork
  threaded:     no
    forked:     yes (variable process count)

In this case my Server MPM is Prefork but yours may be different. On my Debian server running Apache2 it is Worker:

# /usr/sbin/apache2 -V
Server version: Apache/2.2.9 (Debian)
Server MPM:     Worker

On some machines (such as RedHat) it is not uncommon for both prefork and worker binaries to be present (one called httpd and another called httpd.worker or something similar). You may want to double-check (using ps or top or cat /etc/init.d/httpd) which is actually being launched.

share|improve this answer
    
This. Also, prefork is a memory hog so I would use Worker where possible. Though you may need to verify that Worker is stable when combined with your modules. –  CarpeNoctem Dec 22 '10 at 10:17
    
People often use prefork with modules that cannot be threaded such as mod_perl. –  PP. Dec 22 '10 at 11:53
    
Thanks for your reply PP. I'm definitely using Prefork. Any reason why there's more processes running than what I specified in my config? –  Josh Nankin Dec 22 '10 at 15:38

I feel kind of stupid now, but this: Why does htop show lots of apache2 processes by ps aux doesn't? explains my problem.

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.