Apache 2.x + Tomcat 4.x + Load Balancing

This article contains step by step instructions for configuring an Apache 2.x web server which handles static content and delegates JSP (Java Server Pages) and Servlet requests to two Tomcat 4.x servers using AJP 13 connectors and a load balancing worker.


Apache 2.0 is a standards compliant, fast and mature web server which excels at delivering static content such as static HTML pages and images. The Tomcat web server is great for serving Java Server Pages and servlets, but it is not as fast as Apache for delivering static content.

In order to build a fast, scalable web application, the requirements call for an Apache server that delegates servicing of JSP and servlet requests to multiple tomcat servers by using an Apache module, mod_jk, that performs load balancing with session affinity, also known as “sticky” sessions.

Session affinity explained. When a client browser requests a JSP page for the first time, the load balancer redirects the request received by Apache to one of the two tomcat servers; further requests originating from the same client session will be automatically forwarded to the same tomcat server, so that the user’s session data is retrieved.

This document describes how I configured Apache 2.x to dispatch JSP and servlet requests to two Tomcat 4.x instances listening on different ports. This setup was done on a Linux system. Your mileage may vary.

Read more

Related Posts:

6 Responses

ring » Blog Archive » Apache 2.x + Tomcat 4.x + Load Balancing « JavaTechie February 12, 2009 at 10:41 am

[…] unknown wrote an interesting post today onHere’s a quick excerptNow we will create a file called worker.properties, and we will place it under /usr/local/apache2/conf. The worker.properties file tells Apache about the various Tomcat servers that are running, and on which port they are listening. In my setup, I installed the two Tomcat … Until then all work is redirected to peer # worker. worker.loadbalancer.type=lb worker.loadbalancer.balanced_workers=tomcat1, tomcat2 # # END workers.properties #. That’s it, we’re done with Apache. … […]

Mike February 12, 2009 at 10:41 am

Just passing by.Btw, your website have great content!

Colfliaineece February 12, 2009 at 10:41 am


cojusibojepi February 12, 2009 at 10:41 am

My friend on Orkut shared this link with me and I’m not dissapointed at all that I came here.

dammitAdam February 12, 2009 at 10:41 am

I’ve got to ask – why not use mod_proxy_ajp? it supports load balancing (mod_proxy_balance), JsessionID for session affinity, and a variety of load balancing methods.

Check out my quick and dirty here: http://shatnerandsulu.wikidot.com/apache

This is about 100x simpler than what you have described here, but does require apache 2.2.

Great blog by the way!

Apache Linux Tomcat configuration « Creativity never stops February 12, 2009 at 10:41 am

[…] Apache 2.x + Tomcat 4.x + Load Balancing Tutor […]

Comments are closed.