I have configured the HttpServer2.2
to achieve the load balancing
and the Clustering
for my java application.
But the Load Balancing
works fine and Clustering(session replication)
not works .
My worker.properties
in HttpServer
will be ,
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 with SESSION ID's
# should be routed back to the same #Tomcat worker.
worker.balancer.sticky_session =True
and the httpd.conf
will 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 my server.xml
for 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 my server.xml
for 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 the problem.
When I shutdown the Tomcat one
,the new request will be automatically goes to the tomcat two
. But the Tomcat two
doesn't know about the current user state and his stored session object of the application.
hope our stack members will help me with this.
Good answers are definitely appreciated.
Some comments/suggestions
EDIT:
In your configuration you are mentioning
worker.balancer.sticky_session =True
this will make the HttpServer to send all the request to a tomcat where the session was created for first time (the session is stuck to that server hence the name sticky session). This defeats your purpose of session clustering. Please set this to false.