2

This is currently my environment setup.

Apache Tomcat: Apache-Tomacat-7.0.21

Apache HTTP Server: c. Apache HTTP Server 2.2.19

Tomcat Connector JK 1.2.32 for Apache HTTP Server 2, mod_jk

I'm trying to implement sticky session but i still can't get it to work. I'm able to load balance between 2 machines in a cluster. Please advise what else i have missed out!

Following is my workers.properties file

# Define 2 real workers using ajp13 & 1 balancer
worker.list=balancer

#
worker.balancer.type=lb
worker.balancer.balance_workers=worker1,worker2
worker.balancer.sticky_session=True

# Set properties for worker1 (ajp13)
worker.worker1.type=ajp13
worker.worker1.host=localhost
worker.worker1.port=8009
worker.worker1.lbfactor=50
worker.worker1.cachesize=10
worker.worker1.cache_timeout=600
worker.worker1.socket_keepalive=1
worker.worker1.recycle_timeout=300

# Set properties for worker2 (ajp13)
worker.worker2.type=ajp13
worker.worker2.host=X.X.X.X
worker.worker2.port=8009
worker.worker2.lbfactor=50
worker.worker2.cachesize=10
worker.worker2.cache_timeout=600
worker.worker2.socket_keepalive=1
worker.worker2.recycle_timeout=300

I've also set the jvmRoute in server.xml to:

<Engine name="Catalina" defaultHost="localhost" jvmRoute="worker1">
Wen Jun
  • 522
  • 3
  • 9
  • 19
  • Have you uncommented the `Cluster` in server.xml and defined all of it – JoseK Sep 16 '11 at 10:39
  • and just checking on host 2 you set the `jvmRoute="worker2"` – JoseK Sep 16 '11 at 10:52
  • BTW, our next task is to implement session replication. We are current using tomcat example, cart.jsp to demonstrate this behavior. It is said that all session attribute must implement java.io.serializable.Do you have any tips on where to implement it? We are following this tutorial closely. http://tomcat.apache.org/tomcat-6.0-doc/cluster-howto.html – Wen Jun Sep 16 '11 at 12:02
  • thats a separate question to ask. please do so. – JoseK Sep 16 '11 at 12:03
  • Thanks! we have managed to solve the session stickiness! – Wen Jun Sep 16 '11 at 12:05
  • http://stackoverflow.com/questions/7444463/session-replication-does-not-work Can you take a look at this question? Thanks.. – Wen Jun Sep 16 '11 at 12:11
  • 1
    Hi Wen, I know it's too late to ask on this post. But how did you solve session stickiness? We are also using the same kind of workers.properties file with **worker.balancer.sticky_session=True** but still the user gets logged out in between. – aayushdriger Jun 23 '14 at 05:20

0 Answers0