To test the load balancing of Tomcat, I have to start several Tomcat instances on my Windows system. I found some hints about running Tomcat instances on the same system from the Web, but they did not help me so
much. The method I figured out is as follows:
- Download the zip version of core release of Tomcat, and unzip it to a directory where will be the Home of one Tomcat instance, say c:\tomcat0. Read the RUNNING.txt in the directory. The “Advanced Configuration - Multiple Tomcat Instances” part will help you a lot during the further configurations.
- Download the Tomcat Native library and put it in the \bin if you want to improve Tomcat’s performance.
- In server.xml, change the ports for connections to avoid conflict with other applications including other tomcat instances. Add jvmRoute=”tomcat0” into the line of < Engine name="Catalina"
defaultHost="localhost" > to specify the route required in < proxy/ > entry of httpd.conf.
- At the beginning of startup.bat and shutdown.bat, set both CATALINA_HOME and CATALINA_BASE to be c:\tomcat0.
- Copy the folder c:\tomcat0 to c:\tomcat1 to create another Home for an instance, and change its server.xml, startup.bat and shutdown.bat correspondingly.
Now you can run startup.bat in c:\tomcat0 to get the Tomcat instance of tomcat0, and the same for instance of tomcat1, and so on.
I have tried both ajp and http connections to forward the request from Apache proxy to Tomcat instances, and using JMeter to test the performance of both options. Unfortunately, ajp always triggers exceptions related to socket connections. My Tomcat log is quite similar to those catched when using mod_jk . I am not sure if that mean we cannot avoid the bugs in org.apache.jk package even if switching from mod_jk to mod_proxy_ajp. Therefore I suggest to use http to connect Tomcat with Apache other than ajp at this moment.