How to configure Apache/Tomcat in Load Balanced configuration?

You will need to configure both Apache and Tomcat for this purpose. Let us assume you want to load balance two Tomcat Servers against an Apache instance. Apache, first tomcat, second tomcat, all can be on the same machine(hardware) OR they can be in three different machines (each on its own); this configuration will work.

The below mentioned configuration shows all three running on the same host( (You must install tomcat twice ofcourse in different directories, so that you have two tomcats, ofcourse since they are on the same host both tomcats must run on different http ports, say first one on 8080, and second one on 9090. This config is present in <Tomcat_Home>/conf/server.xml file).

Apache Configuration

———-<Apache_Home>/conf/ file————–

info=Scoreboard. Requried for reconfiguration and status with multiprocess servers.

# Defines a load balancer named lb. Use even if you only have one machine.
noWorkersMsg=Server Busy please retry after some time.

# Example socket channel, override port and host.




# Map the Tomcat webapp to the Web server uri space


info=Status worker, displays runtime information

info=The Tomcat /jkstatus handler

———end of file——————-

Tomcat Confugration

The only file you will have to modify here is:<Tomcat_Home>/conf/server.xml, yes on both the tomcat servers you are trying to load balance. You have to set up connector port (8009 on first tomcat, 9009 on second tomcat), and jvmRoute (server1 on first tomcat, server2 on second tomcat). You will notice that these values you had defined earlier in file.

So, here is how you would update on first tomcat, the file:<Tomcat_Home>/conf/server.xml

So, AJP 1.3 Connector to be defined as follows(if it is commented out, uncomment it). The relevant line should look like this:

 <Connector port=”8009″ protocol=”AJP/1.3″ protocolHandlerClassName=”org.apache.jk.server.JkCoyoteHandler” redirectPort=”8443″ />

jvmRoute is set up as follows:

   <Engine name=”Catalina” defaultHost=”localhost” jvmRoute=”server1″>

Similar changes you must make to the second tomcat.

You are all set.

Tested on: Apache 2.2.6, Tomcat 6, Linux



One response

  1. […] details on how to setup Apache/Tomcat to talk to one another, see the relevant post here. Possibly related posts: (automatically generated)ILWACOBusselton JettyCycle Trip to East Coast […]

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: