November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

How to setup a load balanced Tomcat cluster using the Apache TomcatConnector – AJP

Two weeks ago, I tested a Barracuda Load Balancer Model 340.

I liked it a lot, all features I needed, quick and easy deployment and administration. No competition for a Citrix VPX 1000 or similar, but it would for sure fulfill all my requirements.

Nevertheless I wanted see if it is possible to save some money and built the same functionalities with Apache. My test setup was the following.

1 1x CentOS 6.2 VM with Apache 2 2x Win 2k8 R2 VMs running a Tomcat web server 3 1x Win 2k8 R2 VM running the MSSQL DBMS backend

My challenge: The Linux box should act as a LoadBalancer in front of the two Tomcat servers. SSL offloading on the Apache can be added later on, mod_security and mod_rewrite can be added as well. And in order to make it bulletproof, keepalived could help making this setup HA.

Here is my very basic config:

Apache 2.2 configuration: # create a virtual host and a Proxy balancer #/etc/httpd/conf.d/vhosts.conf

LoadModule proxy_module modules/mod_proxy.so

 LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

LoadModule proxy_ajp_module modules/mod_proxy_ajp.so

<Proxy balancer://cluster1>   

BalancerMember ajp://web1.westwind.cx:8009  

BalancerMember ajp://web2.westwind.cx:8009   

ProxySet lbmethod=bytraffic

</Proxy>

<VirtualHost *:80>  

 ServerName www.westwind.cx  

 ProxyPass / balancer://cluster1/ 

 ProxyPassReverse / balancer://cluster1/

</VirtualHost>

Tomcat configuration: #create an AJP connector in the conf/server.xml <!– A AJP 1.3 Connector on port 8009 –> <Connector port=”8009″ address=”${jboss.bind.address}”enableLookups=”false” redirectPort=”8443″ debug=”0″protocol=”AJP/1.3″/>

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>