java - session replication and clustering in tomcat? -
i have configured httpserver2.2 achieve load balancing , clusteringfor java application.
but load balancing works fine , clustering(session replication) not works .
my worker.properties in httpserver ,
workers.java_home=c:/program files/java/jdk1.6.0_25 #worker.list=worker1,worker2 worker.list=balancer worker.worker1.port=8009 worker.worker1.host=localhost worker.worker1.type=ajp13 worker.worker1.lbfactor=1 worker.worker2.port=8019 worker.worker2.host=192.168.100.84 worker.worker2.type=ajp13 worker.worker2.lbfactor=1 worker.balancer.type=lb worker.balancer.balance_workers=worker1,worker2 worker.balancer.method=b # specifies whether requests session id's # should routed same #tomcat worker. worker.balancer.sticky_session =true and httpd.conf be,
<ifmodule jk_module> jkworkersfile conf/workers.properties jklogfile logs/mod_jk.log jkloglevel info jkmount /customerchat_v1.02.00 balancer jkmount /customerchat_v1.02.00/* balance </ifmodule> in server.xml tomcat one,
<cluster classname="org.apache.catalina.ha.tcp.simpletcpcluster" channelsendoptions="8"> <manager classname="org.apache.catalina.ha.session.deltamanager" expiresessionsonshutdown="false" notifylistenersonreplication="true"/> <channel classname="org.apache.catalina.tribes.group.groupchannel"> <membership classname="org.apache.catalina.tribes.membership.mcastservice" address="228.0.0.8" port="45564" frequency="500" droptime="3000" /> <receiver classname="org.apache.catalina.tribes.transport.nio.nioreceiver" address="auto" port="4200" autobind="100" selectortimeout="5000" maxthreads="6" /> <sender classname="org.apache.catalina.tribes.transport.replicationtransmitter"> <transport classname="org.apache.catalina.tribes.transport.nio.pooledparallelsender"/> </sender> <interceptor classname="org.apache.catalina.tribes.group.interceptors.tcpfailuredetector"/> <interceptor classname="org.apache.catalina.tribes.group.interceptors.messagedispatch15interceptor"/> </channel> <valve classname="org.apache.catalina.ha.tcp.replicationvalve" filter=".*\.gif;.*\.js;.*\.jpg;.*\.htm;.*\.html;.*\.txt;" /> <deployer classname="org.apache.catalina.ha.deploy.farmwardeployer" tempdir="d:/cluster/temp/war-temp/" deploydir="d:/cluster/temp/war-deploy/" watchdir="d:/cluster/temp/war-listen/" watchenabled="false" /> <clusterlistener classname="org.apache.catalina.ha.session.jvmroutesessionidbinderlistener"/> <clusterlistener classname="org.apache.catalina.ha.session.clustersessionlistener"/> </cluster> in server.xml tomcat two,
<receiver classname="org.apache.catalina.tribes.transport.nio.nioreceiver" address="192.168.0.1" port="4100" autobind="100" selectortimeout="5000" maxthreads="6" /> but still having problem.
when shutdown tomcat one ,the new request automatically goes tomcat two. tomcat two doesn't know current user state , stored session object of application.
hope our stack members me this.
good answers appreciated.
some comments/suggestions
- the configuration have mentioned purely of load-balancing. assume using tomcat behind httpserver (with ajp connector in tomcat).
- httpserver forward request tomcat server. not maintain session of user.
- session maintained in tomcat , and hence should configure tomcat session clustering.
- for tomcat clustering, refer tomcat version specific documentation. here link tomcat 6.0 session clustering.
- once tomcat servers clustered appropriately, session replicated , each server recognize session of users of other server.
edit:
in configuration mentioning
worker.balancer.sticky_session =true this make httpserver send request tomcat session created first time (the session stuck server hence name sticky session). defeats purpose of session clustering. please set false.
Comments
Post a Comment