{"id":1272,"date":"2012-08-31T17:51:18","date_gmt":"2012-08-31T09:51:18","guid":{"rendered":"http:\/\/rmohan.com\/?p=1272"},"modified":"2012-08-31T18:54:13","modified_gmt":"2012-08-31T10:54:13","slug":"how-to-setup-a-load-balanced-tomcat-cluster-using-the-apache-tomcatconnector-ajp","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=1272","title":{"rendered":"How to setup a load balanced Tomcat cluster using the Apache TomcatConnector &#8211; AJP"},"content":{"rendered":"<p>Two weeks ago, I tested a Barracuda Load Balancer Model 340.<\/p>\n<p>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.<\/p>\n<p>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.<\/p>\n<p>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<\/p>\n<p>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.<\/p>\n<p>Here is my very basic config:<\/p>\n<p>Apache 2.2 configuration: # create a virtual host and a Proxy balancer #\/etc\/httpd\/conf.d\/vhosts.conf<\/p>\n<p>LoadModule proxy_module modules\/mod_proxy.so<\/p>\n<p>\u00a0LoadModule proxy_balancer_module modules\/mod_proxy_balancer.so<\/p>\n<p>LoadModule proxy_ajp_module modules\/mod_proxy_ajp.so<\/p>\n<p>&lt;Proxy balancer:\/\/cluster1&gt; \u00a0\u00a0<\/p>\n<p>BalancerMember ajp:\/\/web1.westwind.cx:8009\u00a0\u00a0<\/p>\n<p>BalancerMember ajp:\/\/web2.westwind.cx:8009\u00a0\u00a0\u00a0<\/p>\n<p>ProxySet lbmethod=bytraffic<\/p>\n<p>&lt;\/Proxy&gt;<\/p>\n<p>&lt;VirtualHost *:80&gt; \u00a0<\/p>\n<p>\u00a0ServerName <a href=\"http:\/\/www.westwind.cx\">www.westwind.cx<\/a> \u00a0<\/p>\n<p>\u00a0ProxyPass \/ balancer:\/\/cluster1\/\u00a0<\/p>\n<p>\u00a0ProxyPassReverse \/ balancer:\/\/cluster1\/<\/p>\n<p>&lt;\/VirtualHost&gt;<\/p>\n<p>Tomcat configuration: #create an AJP connector in the conf\/server.xml &lt;!&#8211; A AJP 1.3 Connector on port 8009 &#8211;&gt; &lt;Connector port=&#8221;8009&#8243; address=&#8221;${jboss.bind.address}&#8221;enableLookups=&#8221;false&#8221; redirectPort=&#8221;8443&#8243; debug=&#8221;0&#8243;protocol=&#8221;AJP\/1.3&#8243;\/&gt;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Two weeks ago, I tested a Barracuda Load Balancer Model 340.<\/p>\n<p>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.<\/p>\n<p>Nevertheless I wanted see if it is possible to save some [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[21],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1272"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1272"}],"version-history":[{"count":3,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1272\/revisions"}],"predecessor-version":[{"id":1274,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/1272\/revisions\/1274"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1272"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1272"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1272"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}