Apache Load Balaning sticky session issue

Few doubts in apache load balancing - I want to clear my doubts about apache load balancing.i have configured apache load balancing for two application servers.

  1. When we set load balancing for two application servers then for one connection to application server we will get one jsession id assign to the connection for one application serverIs that mean for that connection apache server will only refer to one application server not go to another application server

  2. route parameter will be added at the end of each jsesion id.If route is not appended at the end of jsessionid is that a issue? and will result in wrong session stickeyness?

I am stuck please help.

You need use mod_jk module (together with Apache2) and in the worker.properties specify something like that:

SERVER 1

worker.mte01a.port=8009 <- port
worker.mte01a.host=server1 <hostname of server 1
worker.mte01a.type=ajp13 < connector
worker.mte01a.lbfactor=1 < level of LB
worker.mte01a.connection_pool_timeout=600 < no explain
worker.mte01a.sticky_session=true < must be true
worker.mte01a.socket_keepalive=true < must be true
worker.mte01a.socket_timeout=360 < default socket timeout
worker.mte01a.socket_connect_timeout=360000 < a good timeout
worker.mte01a.session_cookie=JSESSIONID1 < this parameter need to be the same here and in the line:

<Engine name="jboss.web" jvmRoute="JSESSIONID1" defaultHost="server1">

in the file: (JBOSS AS)
jbossdir/server/mte01/deploy/jboss-web.deployer/server.xml

SERVER 2:
worker.mte01b.port=8009 <- port
worker.mte01b.host=server1 <hostname of server 2
worker.mte01b.type=ajp13 < connector
worker.mte01b.lbfactor=1 < level of LB
worker.mte01b.connection_pool_timeout=600 < no explain
worker.mte01b.sticky_session=true < must be true
worker.mte01b.socket_keepalive=true < must be true
worker.mte01b.socket_timeout=360 < default socket timeout
worker.mte01b.socket_connect_timeout=360000 < a good timeout
worker.mte01b.session_cookie=JSESSIONID1 < this parameter need to be the same here and in the line:

<Engine name="jboss.web" jvmRoute="JSESSIONID1" defaultHost="server2">

in the file: (JBOSS AS)
jbossdir/server/mte01/deploy/jboss-web.deployer/server.xml

I'm using RHEL 5.3, Apache2 and JBoss AS 4.2.2.GA in the example.

Hi,

I am using http not ajp.

You can configure a content switch (multilayer) and solve your problem cuz i don't know how make sticky session without use mod_cluster or mod_jk.

I am using mod_proxy method.
Setup details -

  1. H/W Load Balancer � 2. Two Apache Servers with load balancing and rewrite rule � 3. Two Application servers

Request will be travel 1 � 2 � 3

Queries -

  • <LI style="mso-list: l0 level1 lfo1" class=MsoNormal>When any session is established I can see that requests of that session is going to both the application servers. Unique jsession id is assigned to that request, using that jsessionid request is forwarded to both application servers. Is it expected behavior?
  • In configuration of Apache load balancing what is good configuration

� By Request
� By Traffic

  • In apache configuration we add route parameter in Proxy balancer tag for both application server, then it gets appended to jsessionid like jsessionid=50D8494884F6D4E9FFB8D8946AEB5AC7:s1 and apache server will use this pattern to manage sessions. In my case this route is not added at the end of jsessionid. Is this something which can cause session issue? In log it shows that it is attached to s1/s2 route respectively.

BalancerMember http://server.1 loadfactor=1 route=s1
BalancerMember http://server.2 loadfactor=2 route=s2

  • Sometimes I am getting this error and land me on error code 400 page not found.

[Tue Jun 22 06:17:32 2010] [error] [client 166.23.23.32] Invalid URI in request username=test&password=1234&method%3Alogin=Logga+in&__checkbox_rememberMeChecked=truejpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*, referer: http://server1.server/home.action

This all happen when we are accessing URL using hardware load balancer. If we hit each apache server individually everything is working fine.

Cool, but I think the best way to do that kind of balance would be through content switch or mod_jk module or mod_cluster module. I have three mission-critical environments here in the company using this type of solution.
Anyway, thanks for the mod_proxy's how to.