Multiple Tomcat Load Balancing on single VM with Highly-Available HAproxy

Apache Tomcat is an open source software implementation of the Java Servlet and JavaServer Pages technologies. The Java Servlet and JavaServer Pages specifications are developed under the Java Community Process. Apache Tomcat powers numerous large-scale, mission-critical web applications across a diverse range of industries and organizations.

We have lot of tomcat load balance method but this is simple method to load balance your tomcat application. Lets we discuss multiple Tomcat Load Balancing on single VM.

Important Tomcat Server ports

Connector Port : This is the port where Apache Tomcat listen for the HTTP requests.

Shutdown Port : This port is used when we try to shutdown the Apache Tomcat Server.

AJP (Apache JServ Protocol) Connector Port : The Apache JServ Protocol (AJP) is a binary protocol that can conduct inbound requests from a web server through to an application server that sits behind the web server.

Redirect Port : Any redirection happening inside Apache Tomcat will happen through this port. In Apache TOMCAT there are two instance where redirectPort is mentioned. First one is for the Apache TOMCAT server and other one is for the AJP port.

Do you want to load balance your multiple tomcat on single VM?

Download tomcat on your server different paths and extract it looks like the following folders (tomcat1 and tomcat2).

Tomcat uses a port (defaults to 8005) as a shutdown port. What this means is that to stop all webapps and stop Tomcat cleanly the shutdown scripts make a connection to this port and send the shutdown command.

The startup.sh and shutdown.sh script files make use of catalina.sh for performing the startup and shutdown operations. We shall edit catalina.sh it