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
 
Sharing the load between servers - httpd and Tomcat

Travel plan to Altnabreac If you're running a lot of traffic through an application, it's possible that one web server can't cope ... not so much because of the traffic levels, but because oomph the computer. Customer's applications range from financial to transport planning. The amount of compute behind the calculation of a Melksham to Altnabreac train journey schedule is large, even if the result is a tiny report.

Now you'll want to quote your customer a single URL, won't you, to process all your traffic, and you'll want to save yourself the £40,000 cost of a hardware load balancer. OK ... Scheme:

• A single server running Apache httpd forwarding the hard work to ...
• A whole batch of Apache Tomcat servers (if your application is in Java) which are doing all the compute and working out that you need to change at Chippenham, Paddington, Euston and Inverness!

You can do this very nicely, and the modern way of connecting the two servers is using mod_proxy_balancer. It's supplied with httpd (no need to source it extra and build it) and it's powerful and works well once you've come to terms with the various configuration options.

But then here comes the 'sting in the tail'. "What does a RETURN ticket cost" comes back a follow up request, and you need to ensure that your visitor is either routed to the same server as he was on before or that the server he gets send to may be a different one, but is aware of the enquiry he is continuing. The first of these approaches (load balancing) is far easier and lower cost in terms of resources than the latter (clustering) which, however, is far more robust in the unlikely event of a Tomcat server going off-line.

There are a number of actions that need to be taken in the configuration of your system to ensure that users DO get routed back to the same server if you take the balance approach:
1. You need to declare a sticky cookie at the Apache httpd mod_proxy_balancer
2. You need to set a jvmroute at the Apache Tomcat
3. Your programmer needs to set up a Session at Your Servlet
and perhaps
4. You need to set up a Reverse Cookie Path.

The Bear, Melksham We've put all this lot in a training example ... and the example we chose was a front end server that receives guests and sends each newly arrived one to a randomly selected put for a drink, but on subsequent visits sends then back to the same pub, secure in the knowledge that they'll feel comfortable and an home there, and will be known to the barman.

Here are the sample files:

The important bit in the httpd.conf configuration file for Apache httpd

<Proxy balancer://barcrawl>
Balancermember ajp://192.168.200.218:8189/bar
Balancermember ajp://192.168.200.214:8189/bar
Balancermember ajp://192.168.200.219:8189/bar
Balancermember ajp://192.168.200.210:8333/bar
Balancermember ajp://192.168.200.215:8189/bar
ProxySet lbmethod=bytraffic
ProxySet stickysession=JSESSIONID
</Proxy>
ProxyPass /bar balancer://barcrawl/
ProxyPassReverseCookiePath /bar /bar


The setting up of the server route in the configuration file for Apache Tomcat - server.xml:

<Engine name="Catalina" defaultHost="localhost" jvmRoute="elm" >

And here are the pertinent lines from within our Barman application, each copy of which has been altered to welcome the visitor to a different pub:

HttpSession session = request.getSession(true);
out.print("<h1>Welcome. Please enter your name</h1>");
out.print("You are in the King Billy<br>");



The Unicorn, Melksham We'll train you on setting up Apache httpd and Tomcat on our Deploying Apache httpd and Tomcat course (but please let us know when you book if you're particularly interested in load balancing and / or clustering and we may suggest an extra day.


The Red Lion, Melksham And we'll train you on Java Programming on our Java Bootcamp if you're already a programmer, or on learning to program in Java if you're a programming novice.

Pictures - Melksham pubs - "The Bear", "The Unicorn" and "The Red Lion"

(written 2009-02-28, updated 2009-03-02)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
A690 - Web Application Deployment - Clustering and load balancing
  [4432] Java web application for teaching - now with sessions and clustering / load balancing demonstrations - (2015-02-20)
  [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)
  [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)


Back to
Invoker and cgi servlets on Tomcat 6
Previous and next
or
Horse's mouth home
Forward to
Database connection Pooling, SSL, and command line deployment - httpd and Tomcat
Some other Articles
Internal Dummy Connections on Apache httpd
Virtual hosting and mod_proxy forwarding of different domains (httpd)
Tomcat 6 - Annotated Sample Configuration Files
Database connection Pooling, SSL, and command line deployment - httpd and Tomcat
Sharing the load between servers - httpd and Tomcat
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
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/2059_Sha ... omcat.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat