Session transparent Tomcat Clustering using Apache mod_jk

Having recently presented an updated instance of my Tomcat Administration training course, I was able to add to the method of combining the previously posted setting of the ‘redistributable’ option for a Tomcat web application (webapp), to allow more or older Tomcat apps to run in a modern Tomcat Cluster.

This focuses around making the distribution of any ‘session’ be fully managed by the Tomcat Cluster, needing no other software to ensure logins and other sessions are retained between pages, clicks and Tomcats servicing the end-user’s browser activity as well.

The usual Java based Cookie that browsers see and use for sessions is called JSESSIONID (but this method supports any and all cookie names) and the operation of the fast and lightweight Apache web server module ‘mod_jk’ works by having the Tomcat jvmRoute name appended to JSESSIONID, for the ‘sticky_session’ activity of mod_jk Load Balancing.

It turns out that with the webapp clustered (via that redistributable=”true” Context that we set, verifiable in the catalina.out via the “session state” cluster messages), you can remove the jvmRoute setting from the Engine for each Tomcat and turn off ‘sticky_session’ in the mod_jk file (worker.WORKERNAME.sticky_session = 0) and restart the Apache and the Clustered Tomcats, and then the JSESSIONID won’t have any jvmRoute appended to it and it’ll be a ‘normal’ Cookie, and mod_jk will just load balance between the configured workers, leaving the Tomcat Cluster to manage the sessions between the clustered Tomcats.

This allows for both transparent High Performance (HP) from your Tomcat Cluster, but also High Availability (HA) through the transparent fail-over of session based cookies and the maintaining of end-user logins etc even when Tomcat servers enter or leave the Tomcat cluster, through the front-line mod_jk Load Balancing.

Please contact us if you’d like more information about using Tomcat, Glassfish, JBoss and WebSphere for your Java Application Server hosting and content delivery.

FYI and regards,

This entry was posted in Network Presence, Sales and tagged , . Bookmark the permalink.