Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
This week, we're updating our course layouts and descriptions. Presentation and materials always gently change over time, but just occasionally there's a need to make a step change to clear out some of the old and roll in the new. That's now happening - but over a long and complex site it's not instant and you'll see sections of the site changing up to and including 19th September.

See also [here] for status update
Load Balancing and Clustering

Too much traffic for a single server? And with so much traffic, do you need robustness such that if one server goes down, (an)other one will take over? You need to split the load - you're looking for a load balancing or clustering solution. But what's the difference?


With a simple LOAD BALANCING scheme, you can split your traffic down by URL or subdirectory, so that (for example) all traffic for /course goes to one server, and all traffic for /horse goes to another, with the front end machine acting simply as a router, forwarding requests via mod_proxy (if it's running Apache httpd) or similar.

Where you have a site that's very broad - i.e. has lots of directories - and the structure of the site is such that no one of them receives the majority of your traffic, this is a good and quick way of increasing throughput. It's not going to do a great deal for you in terms of robustness, although the failure of a back end component won't knock the whole site out, and it's not going to do much for you if you're serving flat pages as they'll be routed back via the front end server anyway.

For details - look up mod_proxy.


This is a scheme that works well for a busy session based application - i.e. one where a visitor arrives at your site and then works through a single or group of applications. Examples include forums, blogs, other CMS systems, booking systems.

When a user first arrives at your site, the front end machine identifies the fact and forwards him on to another machine, selected 'at random' from a group of available back end machines. Subsequent requests by the same user are identified as being a continuation of the same session by the front end machine (using URL rewrite, cookies or hidden fields) and are forwarded to the same back end machine that was previously selected.

This scheme uses Apache httpd mod_rewrite and mod_proxy

Detailed configuration file samples available here
Our examples include files for balancing the load on both Apache httpd servers and Apache Tomcat servers. In other words, as well as using this method to share the load on Java application servers, it can also be used to do the same thing for applications in PHP, Perl, etc.


In Clustering solutions to load sharing, any request made to the front end server may be routed to ANY back end server. A great theory - this is the single queue at your Post Office or McDonald's allowing fair service from the next available team member.

But there's a big problem. Requests are 'atomic' - they're bunched together into a series rather than being made all at once, and somehow you need to ensure that the first team member that you place the first part of your order with informs the second team member with whom you complete your order.

The first, and simplest, approach to clustering is to ensure that all cluster members save pertinent information to a shared database after each atom. Then any subsequent request checks back with that database and continues on with the process in the knowledge of what's gone before.


Rather than use a common database level, Tomcat provides a multicast clustering solution. Here, any files / data modified by a user's activity is broadcast over the network to all other cluster members so that they can keep up to date with the status of all customers.

Multicast Clustering is unlikely to be cheap - although the very use of multicasting ensures that only one transmission of changes is needed (and not one per sibling server), that can still be a lot of traffic and a dedicated 'store back' subnet is recommended. Even then, to double the traffic handled by a single server you're likely to need three back end servers.


Have you noticed that all the solutions offered use a single httpd front end? A hardware load balancer will allow you, if you need to get THAT big, to split that traffic down arbitrarily between a series of available systems, and none of the schemes outlined above requires you to return to the same top level server. Another robustness solution at this top level is to have a "heartbeat" system checking the initial single httpd, ready to take over should it sense a problem.

The database, too, can form a bottleneck. And whereas the front end server can easily switch, that's not quite the case with the database. However, most database applications are "read mostly", so here's a scheme:

- All writes to a single MySQL (master) server
- MySQL master updates replica servers on each cluster member
- All reads from replica servers
- "Heartbeat" monitoring of master server, with scripted fail-over


There's as many different requirements as there are people! Have a look through the options suggested above, and you'll probably see which one has the metrics that best suit you.

If you can get away with a simple load balancing solution, do so - quick and easy. If your user work by sessions, balance the load by sessions using mod_rewrite and mod_proxy - not quite to easy, but a walk in the park compared to clustering solutions. Only cluster if you must!

See also Deploying Apache httpd and Tomcat

Please note that articles in this section of our web site were current and correct to the best of our ability when published, but by the nature of our business may go out of date quite quickly. The quoting of a price, contract term or any other information in this area of our website is NOT an offer to supply now on those terms - please check back via our main web site

Related Material

Web Application Deployment - Tomcat - Extra Features
  [3018] Tuning Apache httpd and Tomcat to work well together - (2010-10-27)
  [1939] mod_proxy_ajp and mod_proxy_balancer examples - (2008-12-13)
  [1899] Virtual Hosting under Tomcat - an example - (2008-11-22)
  [1896] Virtual Hosts and Virtual Servers - (2008-11-20)
  [1383] Monitoring mod_jk and how it is load balancing - (2007-10-07)
  [1377] Load Balancing with Apache mod_jk (httpd/Tomcat) - (2007-10-02)
  [1376] Choosing between mod_proxy and mod_rewrite - (2007-10-02)
  [1370] Apache Tomcat Performance Tuning - (2007-09-29)
  [1121] Sharing the load with Apache httpd and perhaps Tomcat - (2007-03-29)
  [1006] Apache httpd and Apache Tomcat together tips - (2006-12-24)
  [934] Clustering, load balancing, mod_rewrite and mod_proxy - (2006-11-21)

Web Application Deployment - Clustering and load balancing
  [3892] Distributed, Balanced and Clustered Load Sharing - the difference - (2012-10-13)
  [3339] Simplest ever proxy configuration? - (2011-06-28)
  [3293] Distributing the server load - yet ensuring that each user return to the same system (Apache httpd and Tomcat) - (2011-05-18)
  [2483] Clustering on Tomcat - (2009-10-30)
  [2482] Load balancing with sticky sessions (httpd / Tomcat) - (2009-10-29)
  [2059] Sharing the load between servers - httpd and Tomcat - (2009-02-28)
  [1995] Automated server heartbeat and health check - (2009-01-16)
  [1993] Load Balancing - Hardware or Software? - (2009-01-15)
  [1771] More HowTo diagrams - MySQL, Tomcat and Java - (2008-08-24)
  [1121] Sharing the load with Apache httpd and perhaps Tomcat - (2007-03-29)
  [934] Clustering, load balancing, mod_rewrite and mod_proxy - (2006-11-21)

Web Application Deployment - Apache httpd mod_proxy
  [3892] Distributed, Balanced and Clustered Load Sharing - the difference - (2012-10-13)
  [3680] How can I run multiple web servers behind a single IP address? - (2012-04-02)
  [3339] Simplest ever proxy configuration? - (2011-06-28)
  [3293] Distributing the server load - yet ensuring that each user return to the same system (Apache httpd and Tomcat) - (2011-05-18)
  [2482] Load balancing with sticky sessions (httpd / Tomcat) - (2009-10-29)
  [2325] Apache, Tomcat, mod_proxy - (2009-08-06)
  [2273] Three recent questions on Tomcat Convertors - (2009-07-07)
  [2062] Virtual hosting and mod_proxy forwarding of different domains (httpd) - (2009-03-01)
  [1944] Forwarding session and cookie requests from httpd to Tomcat - (2008-12-14)
  [1939] mod_proxy_ajp and mod_proxy_balancer examples - (2008-12-13)
  [1767] mod_proxy and mod_proxy_ajp - httpd - (2008-08-22)
  [1566] Strange behaviour of web directory requests without a trailing slash - (2008-03-06)
  [1376] Choosing between mod_proxy and mod_rewrite - (2007-10-02)
  [1121] Sharing the load with Apache httpd and perhaps Tomcat - (2007-03-29)
  [1006] Apache httpd and Apache Tomcat together tips - (2006-12-24)
  [934] Clustering, load balancing, mod_rewrite and mod_proxy - (2006-11-21)
  [631] Apache httpd to Tomcat - jk v proxy - (2006-03-03)

Web Application Deployment - Apache httpd mod_rewrite
  [3862] Forwarding a whole domain, except for a few directories - Apache http server - (2012-09-17)
  [3753] Adding a passcode to a directory - (2012-06-05)
  [3568] Telling which ServerAlias your visitor used - useful during merging domains - (2012-01-04)
  [3339] Simplest ever proxy configuration? - (2011-06-28)
  [3197] Finding and diverting image requests from rogue domains - (2011-03-08)
  [2981] How to set up short and meaningfull alternative URLs - (2010-10-02)
  [2900] Redirecting a page - silent, temporary or permanent? - (2010-08-03)
  [2773] Dynamically watching your web site via a PHP wrapper - (2010-05-21)
  [2768] Carrying a long URL around - looking for memorable shorts - (2010-05-17)
  [2728] Redirecting a home page using mod_rewrite - (2010-04-17)
  [2555] Bookkeeping - (2009-12-29)
  [2094] If you have a spelling mistake in your URL / page name - (2009-03-21)
  [1954] mod_rewrite for newcomers - (2008-12-20)
  [1778] Pointing all the web pages in a directory at a database - (2008-08-30)
  [1771] More HowTo diagrams - MySQL, Tomcat and Java - (2008-08-24)
  [1731] Apache httpd, MySQL, PHP - installation procedure - (2008-08-01)
  [1636] What to do if the Home Page is missing - (2008-05-08)
  [1381] Using a MySQL database to control mod_rewrite via PHP - (2007-10-06)
  [1376] Choosing between mod_proxy and mod_rewrite - (2007-10-02)
  [1207] Simple but effective use of mod_rewrite (Apache httpd) - (2007-05-27)
  [1009] Passing GET parameters through Apache mod_rewrite - (2006-12-27)
  [1006] Apache httpd and Apache Tomcat together tips - (2006-12-24)
  [934] Clustering, load balancing, mod_rewrite and mod_proxy - (2006-11-21)
  [755] Using different URLs to navigate around a single script - (2006-06-11)
  [631] Apache httpd to Tomcat - jk v proxy - (2006-03-03)

resource index - Deployment
Solutions centre home page

You'll find shorter technical items at The Horse's Mouth and delegate's questions answered at the Opentalk forum.

At Well House Consultants, we provide training courses on subjects such as Ruby, Lua, Perl, Python, Linux, C, C++, Tcl/Tk, Tomcat, PHP and MySQL. We're asked (and answer) many questions, and answers to those which are of general interest are published in this area of our site.

You can Add a comment or ranking to this page

© WELL HOUSE CONSULTANTS LTD., 2014: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 899360 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/solutions/general- ... ering.html • PAGE BUILT: Wed Mar 28 07:47:11 2012 • BUILD SYSTEM: wizard