JavaTechie

Its all about Technology

Apache 2.x + Tomcat 4.x + Load Balancing February 12, 2009

Filed under: Apache, Java — javatechie @ 10:41 am
Tags: , ,

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.

Introduction

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

 

7 Responses to “Apache 2.x + Tomcat 4.x + Load Balancing”

  1. [...] 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. … [...]

  2. Mike Says:

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

  3. Colfliaineece Says:

    FANTASTIC!

  4. cojusibojepi Says:

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

  5. dammitAdam Says:

    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!

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

  7. i have done load balancing with 3 tomcat instances….all r working fine….but when i test the load of 150 user by JMETER…the data display becomes slower??

    what could be the cause ?? plz help


Leave a Reply