AJP13 made easy with mod_proxy
March 18th, 2008 Radim Marek Posted in Administration, jboss |
For a long time mod_jk has been preferred Apache HTTPD plug-in that allowed integration with Tomcat’s JK connectors. It’s certainly perfect solution and still the recommended one for mission critical and highly loaded scenarios.
In case your setup is more relaxed and you looking to do first setup with AJP, there is another solution – mod_proxy. More precisely mod_proxy_ajp that provides ability of handling AJP 1.3 protocol. These modules are enjoying comeback since they have been rewritten for Apache HTTPD 2.2.
Main benefit behind using mod_proxy is the fact that most of the Apache HTTPD installations already come with this module precompiled. Very often not only with HTTP support, but AJP as well. In such a situation administrators feel more tempted to experiment with HTTP based load-balancing scenarios, and therefore more likely to experiment with different protocol.
Let’s have a look how sample configuration would look like:
# Enable Reverse Proxy
ProxyRequests Off
<Proxy balancer://mycluster>
Order deny,allow
Allow from all
# loadfactor = worker load factor
# route = jvmRoute appended to SESSIONID, reflecting setting in server.xml
# min = minimum number of connections to backend server
# max = maximum number of connections to backend server
BalancerMember ajp://192.168.10.33:8009/ loadfactor=10 route=33 min=10 max=50 keepalive=On
BalancerMember ajp://192.168.10.34:8009/ loadfactor=2 route=34 min=10 max=50 keepalive=On
</Proxy>
ProxyPass /proxy balancer://mycluster STICKYSESSION=JSESSIONID|jsessionid nofailover=On
ProxyPassReverse /proxy balancer://mycluster
ProxyPassReverseCookieDomain backend.server public.server
In this case two nodes are created to participate in load-balancer using AJP as connector to backend Tomcat; session affinity enabled with STICKSESSION configuration.
Overall the configuration corresponds with the one you would normally create using mod_jk. Now you’re probably asking what’s the catch. And answer is simple – you loosing dynamic options (periodic reload of mapping), only simplified balancing features and generally the performance is slightly behind mod_jk. My tests during last few months (both with experimental and production grade setups) show difference approximately about 6 – 7% drop down. Something not really worrying if you’re running medium sized intranet solution and you already need clustered solution, or if you just discovering world of load balancing.
For more information, please, check following resources:
June 5th, 2008 at 12:12 am
Hi Radim,
When you say “In case your setup is more relaxed and you looking to do first setup with AJP”, I think you are right!!
Let me tell you my experience with mod_proxy_ajp:
Last week I was setting up a HTTPD + JBoss AS configuration for a production environment and I decided to give mod_proxy_ajp a try. Since its very easy to configure, it would not take me off my course if I tried it.
I didn’t perform any tunning on JBoss or HTTPD. The only settings I modified were the thread limits on HTTPD and AJP connector and limited my database connections to 50% of the HTTP allowed connections.
Then I started JMeter and coded a simple test which accessed a web page that shows some data that is stored on the database.
When I ran the test with more clients than maxThreads, the problems came. The main symptom was hanged threads in apache which would timeout after a few minutes and were never attended…
I didn’t perform more tests with mod_proxy_ajp and switched back to mod_jk.
When I finnished, I ran the same tests and that “hangged requests” behaviour in HTTPD disappeared.
Every request ended up being responded. It was just a matter of time, but now that’s an optimization process :-)