Using ProxyPassMatch

Building on from the Clustering Railo with Tomcat and Apache article we set up the Railo Tomcat cluster but it was set up to send all requests on to Tomcat. While in a low traffic site sending every single request to Tomcat for processing may not be a big deal, you probably haven't gone through the trouble of setting up a cluster for a low traffic environment therefore, you certainly want to squeeze as much performance out of your available resources.

There are a number of ways to do this:

  1. You could place a proxy server like nginx in front of Apache to serve all the static files.
  2. You could use ProxyPassMatch to tell Apache to send only cfm and cfc requests to Tomcat and let Apache serve the static content.

We are going to do the second choice and let Apache handle the static content and pass only the dynamic request on to Tomcat. To do this we will use the ProxyPassMatch Directive which allows us to construct a regular expression and will replace the ProxyPass Directive we used before. This is how the proxy information in your vhosts.conf file looks like now.


<Proxy balancer://mycluster>
BalancerMember ajp://<your server1 ip>:8009/ route=node1 loadfactor=1
ProxySet lbmethod=byrequests
</Proxy>
ProxyPreserveHost On
ProxyPass / balancer://mycluster/ nofailover=On
And this is what it should look like after using ProxyPassMatch

<Proxy balancer://mycluster>
BalancerMember ajp://<your server1 ip>:8009/ route=node1 loadfactor=1
ProxySet lbmethod=byrequests
</Proxy>
ProxyPreserveHost On
ProxyPassMatch ^/(.*\.cf[cm]/?.*)$ balancer://mycluster/$1 nofailover=On

The only real difference is the conversion of the ProxyPass directive to ProxyPassMatch, as was said earlier this will pass only cfm and cfc calls on to Tomcat and let Apache deal with all of the static files. This means you need to set up a 404 handler in Apache for missing files, and subsequently a missing template handler for missing cfc or cfm files.

Using ProxyPassMatch should help you squeeze more performance out of your machine since Tomcat will now only be involved in processing Coldfusion instead of having to return static content as well. You should still tune your jvm settings as suggested by Railo and do other performance tuning exercises based on your specific needs.

This entry is cross-posted on my company's blog under the title Using ProxyPassMatch In Clustering.

Related Blog Entries

0 Comments to "Using ProxyPassMatch"- Add Yours

Powered By Railo

Subscribe

Subscribe via RSS
Follow garyrgilbert on Twitter Follow me on Twitter
Or, Receive daily updates via email.

Tags

adobe air ajax apple cf community cfml coldfusion examples ext flash flex google javascript max2007 max2008 misc open source programming railo software technology ui

Recent Entries

Who is Hosting Railo?
Ask Gary: Spry Tabs
Adobe CF XML Issue - Resolved

Blogroll

An Architect's View
CFSilence
Rey Bango
TalkingTree

Wish List

My Amazon.com Wish List