Why does Apache say there are 49 idle workers when there should be only 10

apache-2.2

I have enabled apache mod_status module with ExtendedStatus enabled too. Since I configured the server status to run only locally:

// httpd.conf
<Location /server-status>
  SetHandler server-status
  Order deny,allow
  Deny from all
  Allow from 127.0.0.1 ::1
</Location>

I use lynx to connect to it:

lynx http://localhost/server-status

This is the output:

   Server Version: Apache/2.2.22 (Ubuntu)
   Server Built: Mar 19 2014 21:10:46
     ________________________________________________________________________________________________________________________

   Current Time: Sunday, 04-May-2014 23:13:58 EDT
   Restart Time: Sunday, 04-May-2014 23:13:35 EDT
   Parent Server Generation: 0
   Server uptime: 23 seconds
   Total accesses: 0 - Total Traffic: 0 kB
   CPU Usage: u0 s0 cu0 cs0
   0 requests/sec - 0 B/second -
   1 requests currently being processed, 49 idle workers

_________________________.......................................
_____W___________________.......................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................
................................................................

   Scoreboard Key:
   "_" Waiting for Connection, "S" Starting up, "R" Reading Request,
   "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup,
   "C" Closing connection, "L" Logging, "G" Gracefully finishing,
   "I" Idle cleanup of worker, "." Open slot with no current process

   Srv PID   Acc  M CPU  SS    Req    Conn Child Slot  Client     VHost             Request
   1-0 8658 0/0/0 W 0.00 0  899699703 0.0  0.00  0.00 127.0.0.1 127.0.1.1 GET /server-status HTTP/1.0
     ________________________________________________________________________________________________________________________

    Srv  Child Server number - generation
    PID  OS process ID
    Acc  Number of accesses this connection / this child / this slot
     M   Mode of operation
    CPU  CPU usage, number of seconds
    SS   Seconds since beginning of most recent request
    Req  Milliseconds required to process most recent request

Huh? 49 idle workers it says? But if you look at the mpm prefork configuration in apache2.conf:

<IfModule mpm_prefork_module>
    StartServers          5
    MinSpareServers       5
    MaxSpareServers      10
    MaxClients          150
    MaxRequestsPerChild   0
</IfModule>

It says start with 5 spawned child processes, and leave 5 hanging around. Thus, there should be a total of 10 apache processes. Where does this 49 come from?

Best Answer

My apologies if you know this already, but just to be clear, the Min and MaxSpareServers are suggestions for the number of idle workers. Apache can and will go above or below these configured values. MaxClients is a dead limit, in mpm_prefork's case the limit on the forked workers.

As for why you're at 49 idle workers, Apache should only respond to client client load. If this is a recently restarted server then there must be something that chews up workers upon startup. If it's not recently restarted then Apache will adjust it's long term target for idle workers, and it's probably around 50 currently. There could be other reasons, owning to your configuration...