Why do you have multiple copies of "httpd" running on your web server, even though you have only got one process in startup? It's because httpd spawns child processes which allow it to be handling several customers at the same time rather than have them stand in line and be processed sequentially. It's sensible / necessary because some of the clients may be a little bit slow (waiting on resources such as disc or network transfer) and rather than wait, the cpu should get on with other jobs.
There are various different models available within httpd ... I'm looking at the default prefork module here, and it's very tune-able. To understand how, I'll compare it with a supermarket checkout.
A supermarket has a certain amount of space available with checkouts installed, but when they open they only open a few at first. As they get busier, more are opened to keep ahead of the rush up to the maximum they have capacity for, and as business drops off, they will close some down - but they'll never drop below a minimum waiting to serve. After a certain number of customers, they may choose to service and then reopen a checkout.
Let's see how the mpm_prefork module does that. Firstly, in the httpd.conf file, you'll enable the extra configuration file to allow you to move it away from all the defaults:
# Server-pool management (MPM specific)
The change was as simple as removing a #
. Then make changes to the file in the extra
subdirectory to reflect the new configuration you want. Let me translate the default into Supermarket terms:
"Our store has 150 checkouts. Five of them are manned when the store is initially opened for business, and we always keep at least five in hand waiting to serve customers who walk up (until all are open). At times that our checkout staff are handling customers quicker than they're arriving, we'll close checkouts but we'll keep at least ten open anyway in case more people walk up. We do not set a limit for the number of customers an individual operator / checkout looks after in a single opening."
There is further tuning of the checkout behaviour which can be changed too, via other defaults. Once again, if you want to change these parameters you need to enable the settings via an extra file - here's the modified line (again, uncommenting is all I changed) in the httpd.conf:
# Various default settings
And here are the default settings that I'm interested in:
"If someone walks up to a checkout but then doesn't actually give the clerk anything to checkout or just stops, give that person 300 seconds to actually get on with something before you chuck 'em and move on to the next customer. When you finish selling something to someone, pause for up to 5 seconds to see if they have another item to purchase as well. But only a hundred of the checkouts may be tied up in this wait state at any time".
There are several different approaches to tuning these settings ... and also to tuning any back room services (such as MySQL) which the staff on the checkouts will be using:
• you could increase the number of checkouts available in order to reduce the amount of shutting down and starting up necessary, and to ensure that you have plenty of staff available at peak times or ...
• you could trim back and have a limited number of checkouts available that move quickly from one customer to the next, scarsely pausing for the slowcoaches.
The defaults are pretty middle - of - the - road, and the fact that you are reading this article is likely to mean you have issues - so have a look at the underlying cause before you do too much and be prepared to do a few tests!
. Monitoring tools include top, vmstat and uptime
from Linux, the Apache Server Status
page from httpd that you can enable, mysqladmin status
from MySQL ... and you can use tools such as ab
to generate traffic flows too to test your system.
To conclude - three sample (amended) configuration files ...
Keeping a lot more checkouts open (but be careful that you don't end up paying so much overtime (i.e. using swap space) that you loose more that you gain:
For a system which has limited memory ("you don't really want the expense and time consuming trouble of serving people in a portacabin, so make the very best use of your limited floor space!"):
And here are some tunings for the default file:
Here's the rationale behind that one: "It's a fast moving site, and (let's face it!) people will get bored after waiting for a minute - so may as well time out them. Keep the number of checkouts waiting for a further purchase down; avoid the danger of the whole store being clogged up with checkouts waiting for Mrs Jones to run back for some sugar, or for Johnny Smith to dash over and get an extra Mars bar because he hadn't noticed the 2 for 1 offer. And keep the time that Mrs J and Johnny are allowed for such antisocial actions down."
; The image illustrating this article is public domain. detail
. (written 2009-02-26, updated 2010-10-28)
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articlesA601 - Web Application Deployment - Apache httpd - an overview 
Public training courses - upcoming dates - (2015-02-21) 
Apache httpd - a robust, open source web server - (2013-04-16) 
An FAQ on the Apache httpd and Apache Tomcat web servers, and on using them together - (2009-05-17) 
Why put Apache httpd in front of Apache Tomcat - (2009-03-12) 
Internal Dummy Connections on Apache httpd - (2009-03-02) 
Sticky Sessions with mod_jk (httpd to Tomcat) - (2009-02-12) 
Apache httpd and Apache Tomcat miscellany - (2009-01-30) 
Keeping on an even keel - (2008-11-21) 
Keep the client experience easy - single server contact point - (2008-03-27) 
Apache, Tomcat, Jakarta, httpd, web server - what are they? - (2007-07-13) 
The LAMP Cookbook - Linux, Apache, MySQL, PHP / Perl - (2006-11-13) 
Web Application Components - (2006-03-28) 
Why run two different web servers - (2006-01-25)
Some other Articles
Invoker and cgi servlets on Tomcat 6Train and Coach fares from London (and airports) to MelkshamWeb Site Loading - experiences and some solutions sharedEffect on server when memory runs out and swapping startsTuning httpd / the supermarket checkout comparisonWhat a difference a MySQL Index madeHow was my web site compromised?A Presentation about our company - web and PHPWhy the Pony Tail?Why Choose Well House Consultants for your course?