3-node cluster with stickySession and failover
rmdavidson Oct 25, 2009 8:50 PMHi everyone,
I've managed to mostly get mod_cluster working in a cluster with two Apache load-balancer boxes running mod_cluster 1.0.2.GA and 3 JBossAS 4.2.3.GA nodes.
Sticky sessions are working well in general - people are being routed to various web nodes and their sessions are sticky to those nodes.
I've been playing with the stickySessionRemove and stickySessionForce settings. If I understand correctly, stickySessionRemove should remove the cookie if the session can not be routed to the node its stuck to, eg. if that node goes offline. If thats the case, then shouldn't the cookie be updated to contain the name of a node that IS running,possibly on the second request?
What I'm trying to achieve is to have a 3 node cluster, with sticky sessions. When one node dies, the sessions assigned to that node should be re-assigned to other nodes in the cluster as needed. The cookie should then be updated and the user will be stuck to a new node.
Our 3 JBossAS node jvmRoute settings are ws01, ws02 and ws03. If a user is stuck to node ws02 for example, and I shut down this node, they will be routed to either node ws01 or ws03. Their JSESSIONID cookie is not updated and still has ".ws02" appended to the end. So I'm guessing that since this jvmRoute is now dead, mod_cluster is sending the request to any available node, but its also NOT updating the cookie. Is it possible to get mod_cluster to update the cookie to a valid node automatically?
JBossAS Config (jboss-web.deployer/server.xml):
<Listener className="org.jboss.modcluster.ModClusterListener" advertise="false" proxyList="lb1:80,lb2:80" excludedContexts="ROOT,invoker,jbossmq-httpil,jbossws,jmx-console,juddi,web-console" balancer="mybal" domain="mydomain.example.com" stickySession="true" stickySessionForce="false" stickySessionRemove="true" nodeTimeout="300"/>
Then further down, in the same file, under the AJP connector section, we have:
<Engine name="jboss.web" defaultHost="localhost" jvmRoute="ws01">
In Apache, the following config applies. Basic mod_cluster config:
LoadModule slotmem_module modules/mod_slotmem.so LoadModule manager_module modules/mod_manager.so LoadModule proxy_cluster_module modules/mod_proxy_cluster.so LoadModule advertise_module modules/mod_advertise.so <Location /mod_cluster-manager> SetHandler mod_cluster-manager Order deny,allow Deny from all Allow from 127.0.0.1 Allow from xxx.xxx.xxx.xxx </Location>
Apache virtualhost configuration:
<VirtualHost *:80> ServerName mydomain.example.com ManagerBalancerName mybal ServerAdvertise off CreateBalancers 1 ProxyPass / balancer://mybal/ stickysession=JSESSIONID </VirtualHost>