in Uncategorized

Tomcat clustering

In this tutorial I will share how to setup two tomcat nodes with FramWarDeployer, this will allow you to autodeploy all wars to all nodes automatically with session sharing cross cluster.

Tomcat Cluster configuration

Assuming that you have downloaded and installed both tomcats, you must update server.xml located in config folder of the tomcats.

Locate the Server -> Service -> Engine and set jvmRoute  attribute to tomcat1 and tomcat2 like this:

Locate Server -> Service -> Engine -> Host and add :

For the second tomcat you can if you choose so to use different receiver port.

Observe that there are two Manager tags, one is for BackupManager and other is for DeltaManager. Both are used for session replication.

  • DeltaManager copies sessions to all other nodes
  • BackupManager copies to only one node, with this difference there is a huge difference in performance when more then two nodes are included.

Check the load test results for both managers here.

FarmWarDeployer

To setup auto deployment cross cluster you need to add FarmWarDeployer , in each server.xml you should add the with corrections in deployDir and tempDir paths. With enabling watchEnabled to only one tomcat that you think of as manager.

After you add/edit/remove war file in watchDir this war will be automatically deployed cross your cluster.

Load balancing with apache2

To allow load balancing with apache2 you should utilize this configuration:

Problem with it is that two consecutive requests from same user/client might not go to the same tomcat. This can be a problem depending of the manager you used to configure the cluster and of how many tomcats you have. If this is a problem you can simply setup load balancing with stickiness, you can read more on apache2 mod_proxy documentation page. Here is the example.

 

To force the server to listen to IP v4 instead of IPv6 set next line into bin/setenv.sh .

 

I hope that this post was helpful to you.

 

 

Write a Comment

Comment