Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
Sticky Sessions with mod_jk (httpd to Tomcat)

If you're load balancing with mod_jk, you can put a load balancer worker in your jk properties file, and then have requests forwarded to all the workers that are members of that load balancer. That's a great way to share the load.

But if you're running applications that rely on a series of linked pages (sessions) the you really don't want your client's requests to be forwarded at random - you want to pass them back to the same worker they were talking to last time. In real life, this is like saying that if you go into a shop, you can pay at any till, but if you make a series of telephone calls to sort out a complicated utility bill you really want to get through to the same clerk to serve you each time.

You can set up this "sent back to the same person" scenario if your application is written using Java's session classes; in the workers configuration file add a line to specify the domain for each host, and a line to set sticky sessions on in the balance worker:


In your Tomcat configuration file on EVERY server, set the jvmRoute of the engine to be the same as the domain name stated in the worker entry - for example:

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

Remember that is you stop and start your various servers during testing, that will NOT have reset / cleared the cookies held at the browsers you are testing from and you may see some odd effects - what you are doing is like changing a program, but saving the variables. It's a good idea to stop everything, clear out all relevant cookies and caches, and restart as a final test before releasing the system to users.

If you are using mod_jk and have turned sticky sessions on, but your sessions are failing to stick, you have probably failed to set the domain, or you have failed to set the jvmRoute, or you are using a non-standard cookie name to implement the stickyness!

With Apache 2.2, mod_proxy_balancer has replaced many uses of mod_jk; similar setup principles apply - there are more mod_proxy resources here and here.

We cover the connection of Apache httpd to Apache Tomcat on our public Deploying Apache httpd and Tomcat course, and we also cover them as appropriate on private courses; the examples above come from this afternoon's examples on a private course.

Footnote - although the build documentation for mod_jk talks about Apache 1.3 and Apache 2.0, the (2.0) scheme works perfectly well for you to build for 2.2. However, once you have built a mod_jk library, that built file will ONLY work reliably with the version / subversion you built it for. It's no good getting someone else's 2.0.43 and expecting it to work on 2.0.44!
(written 2009-02-12, updated 2009-02-13)

Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
A601 - Web Application Deployment - Apache httpd - an overview
  [576] Why run two different web servers - (2006-01-25)
  [659] Web Application Components - (2006-03-28)
  [924] The LAMP Cookbook - Linux, Apache, MySQL, PHP / Perl - (2006-11-13)
  [1265] Apache, Tomcat, Jakarta, httpd, web server - what are they? - (2007-07-13)
  [1593] Keep the client experience easy - single server contact point - (2008-03-27)
  [1897] Keeping on an even keel - (2008-11-21)
  [2016] Apache httpd and Apache Tomcat miscellany - (2009-01-30)
  [2054] Tuning httpd / the supermarket checkout comparison - (2009-02-26)
  [2063] Internal Dummy Connections on Apache httpd - (2009-03-02)
  [2077] Why put Apache httpd in front of Apache Tomcat - (2009-03-12)
  [2186] An FAQ on the Apache httpd and Apache Tomcat web servers, and on using them together - (2009-05-17)
  [4064] Apache httpd - a robust, open source web server - (2013-04-16)
  [4434] Public training courses - upcoming dates - (2015-02-21)

Back to
The Interview and The Lift
Previous and next
Horse's mouth home
Forward to
The Invoker
Some other Articles
Wiltshire Rail Service Update
httpd, Tomcat and PHP course enhancements
Error: Cant read xxxxx: no such variable (in Tcl Tk)
The Invoker
Sticky Sessions with mod_jk (httpd to Tomcat)
The Interview and The Lift
Java Tag Libraries / how they work / Tomcat Deployment
1234567890 ... coming up on Friday 13th
Through Snow and Flood to Linux and Tomcat
Huawei D100 Wireless Router - Mobile Internet
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., 2024: 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/2038_Sti ... mcat-.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb