Tech Blog

proxy_http vs proxy_ajp benchmark

Posted At : March 18, 2010 1:20 AM 2 Comments

After I posted a previous blog entry about configuring railo & tomcat with apache and mod_proxy_http, Paul Kukiel and Gary Gilbert suggested that I should be using mod_proxy_ajp.

This has been something I've been looking at, but haven't found a compelling reason for one over the other.

Proxy AJP is claimed to be faster as it is a "Wire protocol" but I couldn't find any benchmarks around this.

So I decided to do a very quick and dirty benchmark to satisfy my curiosity. This is not a scientific process, I just ran a simple railo testpage on the same machine with 50 threads of jmeter requests hitting it.

First I enabled proxy_http and ran it four times, then enabled proxy_ajp and repeated. The config is below:

# Proxy HTTP config
<IfModule mod_proxy_http.c>
   <Proxy *>
   Order deny,allow
   Allow from all
   </Proxy>
   ProxyPassMatch ^/(.*\.cfm)$ http://testsite.railo:8080/$1
   ProxyPassReverse / http://testsite.railo:8080/
</IfModule>

# Proxy AJP config
<IfModule mod_proxy_ajp.c>
   <Proxy *>
   Order deny,allow
   Allow from all
   </Proxy>
   ProxyPassMatch ^/(.*\.cfm)$ ajp://testsite.railo:8009/$1
   ProxyPassReverse / ajp://testsite.railo:8009/
</IfModule>

Results:

RunHTTP Requests/secAJP Requests/sec
Run 1206.9181.4
Run 2203.9143.6
Run 3194.6189.2
Run 4204.6191.4
Average202.5176.4

The results showed that the proxy_http module was faster - i.e. more requests per second could be pushed through.

I'm putting this down to the fact that proxy_ajp has to convert the http request into it's binary format, while proxy_http really just has to pass it along.

In different scenarios and network configurations the results may be different, but for now I'm going to stick with the http proxy.

Proxy AJP has one other benefit, in that is passes along some extra flags such as whether the request is https or not, but for our purposes we don't need this.

Cheers, Mark

2 Comments

Gary Gilbert 3/18/10 8:23 AM

Hi Mark,

For a standalone server, without clustering and support for session stickyness you will notice a better performance using mod_proxy_http, when you start clustering the reverse will be true.

Here is a description from the Tomcat site describing the two connectors

http://tomcat.apache.org/tomcat-5.5-doc/connectors...

Mark Lynch 3/18/10 9:06 AM

Thanks Gary,

That makes sense, and gives a good rule of thumb for when to use each.

Simple setup - use proxy_http
Cluster setup - use proxy_ajp

Cheers,
Mark

Post Your Comments


If you subscribe, any new posts to this thread will be sent to your email address.