Thursday, March 11, 2010

Complete Apache 2.2-AJP Load Balance via mod_proxy

Monday, December 3, 2007, 4:33
This news item was posted in HowTo & Tutorial category and has 5 Comments so far.

Complete guide for apache-http server load balancing via mod_proxy and some performance enhancements

required modules:

proxy_module
proxy_ajp_module
proxy_balancer_module

250px-asf-logosvg.png
1. open your java application AJP connector

for tomcat un comment AJP connector as below

<Connector port=”8009” protocol=”AJP/1.3″ redirectPort=”8443″ />

2. Load Apache modules

include or uncomment those lines at httpd.conf

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so

3. write new httpd-conf as httpd-ajp.conf

<Location /balancer-manager>
SetHandler balancer-manager
</Location>

<Proxy balancer://ajpCluster>
BalancerMember ajp://localhost:8009 route=s1
BalancerMember ajp://localhost:9009 route=s2
BalancerMember ajp://localhost:7009 route=s3
</Proxy>
<Location /jspapp1>
ProxyPass balancer://ajpCluster/jspapp1 stickysession=JSESSIONID
</Location>
<Location /jspapp2>
ProxyPass balancer://ajpCluster/jspapp2 stickysession=JSESSIONID
</Location>


/balancer-manager is to monitor your load balance cluster nodes

you can see fails and last status for java ajp connectors/Servers

http://yourapachehost/balancer-manager

Proxy balancer://ajpCluster

is your load balance /cluster definition for your apache server

in example is assuming 3 java application server with ajp connectors at 7009,8009,9009 working at at localhost

/jspapp1 and /jspapp2 is your jsp/java applications rename it with your application context name

4. Extras (GZip)

define mod_deflate in httpd.conf

LoadModule deflate_module modules/mod_deflate.so

add gzip compression for jspapp s

<Location /jspapp2>
ProxyPass balancer://ajpCluster/jspapp2 stickysession=JSESSIONID
AddOutputFilterByType DEFLATE text/html text/plain text/xml
</Location>

see:

multiple tomcat instance – single setup

Reblog this post [with Zemanta]
Share and Enjoy:
  • Digg
  • del.icio.us
  • Netvouz
  • DZone
  • Wists
  • LinkedIn
  • Slashdot
  • Google Bookmarks
  • Reddit
  • StumbleUpon
  • email
  • Twitter

Related posts:

  1. Configure Apache:virtual host, mod_proxy and mod_proxy_ajp
  2. multiple tomcat instance – single setup
  3. tomcat port configuration
  4. maven profiles

You can leave a response, or trackback from your own site.

5 Responses to “Complete Apache 2.2-AJP Load Balance via mod_proxy”

  1. yongcheolKim said on Thursday, January 31, 2008, 14:29

    참고

  2. bsdplus said on Monday, April 20, 2009, 5:32

    great tips. thank you!

  3. fak3r said on Thursday, May 21, 2009, 14:37

    Great post, this got me proxying requests via ajp_proxy from Apache to multiple virtual Xen instances running tomcat6 on the back end. Very cool, appreciate the effort.

  4. Lovelesh Singh said on Thursday, October 8, 2009, 8:11

    Hi Dear,

    I have configured the same but whenever my one instances goes down applications is not switching on another…..can u guid me ..

    Thanks

  5. altuure said on Thursday, October 8, 2009, 8:56

    hi lovelesh,
    I am not sure but it was working,
    you can check, /balancer-manager if all your applications are running or not ?

    but there can be one problem i guess, your java server may be not dead (its ajp port is still open) but crashed by out-of-memory errors ? and not responding properly !

Leave a Reply