Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Tuning httpd / the supermarket checkout comparison

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.

Supermarket Checkouts 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)
Include conf/extra/httpd-mpm.conf


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:

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


"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
Include conf/extra/httpd-default.conf


And here are the default settings that I'm interested in:

Timeout 300
MaxKeepAliveRequests 100
KeepAliveTimeout 5


"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 and jmeter 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:

<IfModule mpm_prefork_module>
   StartServers 10
   MinSpareServers 10
   MaxSpareServers 25
   MaxClients 250
   MaxRequestsPerChild 10000
</IfModule>


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!"):

<IfModule mpm_prefork_module>
   StartServers 4
   MinSpareServers 4
   MaxSpareServers 8
   MaxClients 35
   MaxRequestsPerChild 10000
</IfModule>


And here are some tunings for the default file:

Timeout 60
MaxKeepAliveRequests 20
KeepAliveTimeout 3


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."

[Sample file]; 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 articles
A601 - Web Application Deployment - Apache httpd - an overview
  [4434] Public training courses - upcoming dates - (2015-02-21)
  [4064] Apache httpd - a robust, open source web server - (2013-04-16)
  [2186] An FAQ on the Apache httpd and Apache Tomcat web servers, and on using them together - (2009-05-17)
  [2077] Why put Apache httpd in front of Apache Tomcat - (2009-03-12)
  [2063] Internal Dummy Connections on Apache httpd - (2009-03-02)
  [2038] Sticky Sessions with mod_jk (httpd to Tomcat) - (2009-02-12)
  [2016] Apache httpd and Apache Tomcat miscellany - (2009-01-30)
  [1897] Keeping on an even keel - (2008-11-21)
  [1593] Keep the client experience easy - single server contact point - (2008-03-27)
  [1265] Apache, Tomcat, Jakarta, httpd, web server - what are they? - (2007-07-13)
  [924] The LAMP Cookbook - Linux, Apache, MySQL, PHP / Perl - (2006-11-13)
  [659] Web Application Components - (2006-03-28)
  [576] Why run two different web servers - (2006-01-25)


Back to
What a difference a MySQL Index made
Previous and next
or
Horse's mouth home
Forward to
Effect on server when memory runs out and swapping starts
Some other Articles
Invoker and cgi servlets on Tomcat 6
Train and Coach fares from London (and airports) to Melksham
Web Site Loading - experiences and some solutions shared
Effect on server when memory runs out and swapping starts
Tuning httpd / the supermarket checkout comparison
What a difference a MySQL Index made
How was my web site compromised?
A Presentation about our company - web and PHP
Why the Pony Tail?
Why Choose Well House Consultants for your course?
4759 posts, page by page
Link to page ... 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 at 50 posts per page


This is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price.

Link to Ezine home page (for reading).
Link to Blogging home page (to add comments).

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2054_Tun ... rison.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat