File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Tomcat and the fly likes Load Balancing Problem with jsessionid Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Reply Bookmark "Load Balancing Problem with jsessionid" Watch "Load Balancing Problem with jsessionid" New topic
Author

Load Balancing Problem with jsessionid

Anirvan Majumdar
Ranch Hand

Joined: Feb 22, 2005
Posts: 261
Hi,

I am using the JK connector methodology for load-balancing 2 Tomcats (5.5) running behind an Apache (2.2.4) web server.
I successfully managed to setup the load balancer for a web application for which session management through cookies was enabled. However, when I tried to setup the same configuration for another application which manages sessions using jsessionid and has cookies disabled, I am facing some trouble.
It appears that inspite of having explicitly set the "sticky_Session" attribute for the balancer worker, requests made by the same session keep on alternating between the 2 Tomcats.

============================
The worker.properties file
============================


In the server.xml for each Tomcat, I've got the "Engine" element as follows:


Session management through Cookies has been disabled for this application. Instead we are using URL encoding to maintain sessions using the jsessionid.

Anyone who can shed some light on this? Really appreciate!
Anirvan Majumdar
Ranch Hand

Joined: Feb 22, 2005
Posts: 261
Well,
Disappointingly there doesn't seem to be any response to my query. However, I've managed to fix the issue myself and am sharing this hoping that it should benefit someone in the future.

The problem with my configuration was that, even though I had correctly declared a load-balancer worker - router - to handle multiple "real" workers - worker1, worker2, worker3; my mistake lied in the <Engine> element declaration for my corresponding Tomcats.

I believe I had read in some "How-to" reference that each Tomcat instance's <Engine> element should point to the load-balancer worker. This, I can claim now, is not correct. Each Tomcat's <Engine> element should point to a unique worker belonging to the list of balanced workers of the load-balancer worker. So it should've actually been:

Tomcat 1 - server.xml


Tomcat 2 - server.xml


Tomcat 3 - server.xml


Hope this helps!
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Anirvan Majumdar:
Well,
Disappointingly there doesn't seem to be any response to my query. However, I've managed to fix the issue myself and am sharing this hoping that it should benefit someone in the future.
...
Hope this helps!


Thank you for posting back with your solution.
There are several approaches to load balancing.
I use sticky sessions at the router level so I wouldn't have been able to answer you question. It could be that, nobody else who has seen your question has run into this problem either.
Again, thanks
-Ben


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: jrebel
 
subject: Load Balancing Problem with jsessionid
 
Similar Threads
mod_jk tomcat 4.1 with apache 1.3.27 on Redhat 7.2 box
Tomcat connector from web server to three workers on apps server
worker2.properties
Apache SSL Module on Ubuntu
Load balancing in Apache Web server not working