Forum Moderators: phranque

Message Too Old, No Replies

Always load balance to same box with different tomcat contexts

         

andrey ilyin

4:01 pm on Jan 20, 2010 (gmt 0)

10+ Year Member



Hi,

I am having a quite serious problem for which I could not find solution.
The configuration:

Apache: 2.2 serving as load balancer

workers.properties
worker.list=balancer

worker.engine1.port=10001
worker.engine1.host=localhost
worker.engine1.type=ajp13
worker.engine1.lbfactor=1

#worker.engine2.port=10002
#worker.engine2.host=localhost
#worker.engine2.type=ajp13
#worker.engine2.lbfactor=1

#worker.engine3.port=10003
#worker.engine3.host=localhost
#worker.engine3.type=ajp13
#worker.engine3.lbfactor=1

worker.balancer.type=lb
worker.balancer.sticky_session=1
worker.balancer.sticky_session_force=1
worker.balancer.balance_workers=engine1,engine2,engine3

3 Tomcat 6 instances with ajp connector with two webapps without session serialization e.g.

<Connector
port="10001"
redirectPort="10011"
connectionTimeout="-1"
protocol="AJP/1.3">
</Connector>

<Context path="/webapp1" distributable="false">
</Context>
<Context path="/webapp2" distributable="false">
</Context>

The problem is that once user logs in into webapp1 and goes to link to webapp2, it's not guarantied that he will go to same box as webapp 1. This results in session lost and sometimes Principal is not correctly setup. Using session serialization is not an option because sessions used in webapp1/webapp2 are very heavy and it results in awfull performance.

Is there a way to force apache to always rebalance to same box for different tomcat contexts?

Thanks,
Andrey.

jdMorgan

4:46 pm on Jan 20, 2010 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



This is a fairly "advanced topic" and beyond my experience, but it would seem on it's face to boil down to the choice between making the "session" visible to the load balancer so that it always "picks" the same back-end once a session is established, or serializing the sessions and upgrading the number and/or type of servers to handle the "awful" load.

You might also get more and better responses in a Tomcat-specific forum, as the number of potential respondents with actual experience would be higher.

Sorry I can't offer anything more useful than that...

Jim