tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brett Neumeier <>
Subject RE: Need help with JK2 & sticky sessions...
Date Fri, 25 Apr 2003 14:36:35 GMT
Luiz-Otavio Zorzella wrote:
> The problem is that sticky sessions are not working at all. In other
> words, each request goes to a different node in my cluster. I need the
> requests that come from a client to always be directed to the same
> server, until (and if) that server dies.

Well, I know how this works with JK1, so perhaps the same thing will apply.
With JK1, the way that load balancing works is that the Tomcat server sets a
JSESSIONID value that includes a unique identifier for that Tomcat service.
The identifier Tomcat uses is the value of the jvmRoute attribute of the
Engine element in server.xml. So for example, if server.xml contains:

<Engine name="Standalone" defaultHost="" debug="0"

then requests to this Tomcat server will get JSESSIONID cookies with values
such as "CE90AB590A14A5DBE4463399638D359E.TC1".

The JK (and, presumably, JK2) connectors look at the value of the JSESSIONID
cookie to determine which Tomcat worker to use for a given request.  I don't
know for sure, but my guess would be that JK2 uses the tomcatId value for
this mapping, so with your configuration:

> []

> []

It looks to me as though JK2 is probably looking to see whether the
JSESSIONID has a value ending in (in which case it
will direct the request to node1) or (in which
case, node2).  If JSESSIONID doesn't end in one of those values, JK2 will
pick a random server to satisfy the request.

Does that make sense?  There's no magic involved in server affinity.  It's
true the documentation isn't particularly clear on the point -- I continue
to plan to submit documentation patches, but (as is with the case for most
of us) I have Too Much To Do these days.



To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message