users@glassfish.java.net

AJP/mod_jk load balancing in a cluster - sticky sessions not so sticky

From: <glassfish_at_javadesktop.org>
Date: Tue, 06 May 2008 00:53:23 PDT

Hi

I've setup a 2 instance cluster and I'm trying to get AJP/mod_jk loadbalancing to work. I followed the instructions here:

http://blogs.sun.com/dadelhardt/entry/loadbalancing_with_mod_jk_and_glassfish

and was able to get the jvmRoute stuff working after reading this thread and installing the patch:

http://forums.java.net/jive/thread.jspa?messageID=242418

My problem now is that my sessions are not sticky, it keeps going round robin between the 2 instances instead of sticking to the same server instance. Using a firefox plugin, I had a look at the http request/response headers and it seems like I'm getting a new JSESSIONID back from the server with every request. I think this is the problem because every request starts a new session.

Any help will be greatly appreciated.

Thanks
Eduard

Here is my workers.properties :

worker.list=loadbalancer
worker.worker1.type=ajp13
worker.worker1.host=fawlinux1
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.socket_keepalive=1
worker.worker1.socket_timeout=300
worker.worker2.type=ajp13
worker.worker2.host=fawlinux2
worker.worker2.port=8010
worker.worker2.lbfactor=50
worker.worker2.socket_keepalive=1
worker.worker2.socket_timeout=300
worker.loadbalancer.type=lb
worker.loadbalancer.balance_workers=worker1,worker2
worker.loadbalancer.sticky_session=true

and the relevant part from httpd.conf:

JkWorkersFile /etc/libapache2-mod-jk/workers.properties
JkLogFile /var/log/apache2/mod_jk.log
JkLogLevel info
JkMount /* loadbalancer
[Message sent by forum member 'eduardp' (eduardp)]

http://forums.java.net/jive/thread.jspa?messageID=272898