proxy_http vs proxy_ajp benchmark

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

FFMpeg conversion - wmv to flv HOWTO

More of a quick note to self about converting video formats:

To convert wmv to flash video:

ffmpeg -i input.wmv -ar 44100 -qmax 8 out.flv

This does the following:

  • -i input.wmv - Load input file
  • -ar 44100 - Resample audio to 44.1kHz.
  • -qmax 8 magic voodoo about quality. Gave better results than not using it.
  • out.flv save it as an flv.

Easy.

Railo on Tomcat revisited - mod_proxy

Updated: Changed the linking between railo and tomcat to use shared.loader.

I've been doing some more work on configuring railo to work flexibly in the numerous different environments we work in, and also making it simpler to set up.

To that end I investigated the use of mod_proxy for linking it to apache instead of mod_jk.

Advantages of this approach are:

  • Simple - communications are in plain http
  • Flexible - Load balancing can be easily added at the apache layer
  • Simple - No compiling mod_jk

Here are the basic install instructions for Railo/Tomcat/Apache on Ubuntu.

Download & Install Tomcat

Download tomcat and extract content:

tar xvzf apache-tomcat-6.0.26.tar.gz

Move Tomcat to a more appropriate place:

sudo mv apache-tomcat-6.0.26 /opt/tomcat

Download Railo

Download Railo custom version jars file

Extract and move into Tomcat lib directory:

tar zxvf railo-3.1.2.001-jars.tar.gz
sudo mv railo-3.1.2.001-jars /opt/railo

Make Tomcat load the railo jars by editing catalina.properties to change the shared loader path:

shared.loader=/opt/railo/*.jar

Make Tomcat and Railo work together by modifying the web config file:

sudo nano -w /opt/tomcat/conf/web.xml

add the following inside the <web-app> element:

<servlet>
<servlet-name>CFMLServlet</servlet-name>
<servlet-class>railo.loader.servlet.CFMLServlet</servlet-class>
<init-param>
<param-name>configuration</param-name>
<param-value>{web-root-directory}/WEB-INF/railo/</param-value>
<description>Configuraton directory</description>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfm</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfml</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>CFMLServlet</servlet-name>
<url-pattern>*.cfc</url-pattern>
</servlet-mapping>

add the following inside <welcome-file-list> element:

<welcome-file>index.cfm</welcome-file>
<welcome-file>index.cfml</welcome-file>

Start up tomcat:

/opt/tomcat/bin/startup.sh
Once this is done you should be able to access the railo admin by going to the following URL:

Back to Tomcat

To test our Railo installation, let's create a test site by adding a new virtual host in both Tomcat and Apache. We do this by modifying Tomcat server.xml file (/opt/tomcat/conf/server.xml )
<Host name="testsite.railo" appBase="webapps">
<Context path="" docBase="/vhosts/testsite.railo/www"/>
</Host>

Linking with Apache via Mod Proxy

Ensure the modules proxy and proxy_http are enabled. On Ubuntu this is done as follows:

sudo a2enmod proxy
sudo a2enmod proxy_http
sudo /etc/init.d/apache2 restart

Create vhost

Now we need to create a virtual host entry in Apache as well:
<VirtualHost *:80>
DocumentRoot /vhosts/testsite.railo/www
ServerName testsite.railo
DirectoryIndex index.cfm
   #Proxy .cfm requests to railo
   <IfModule mod_proxy.c>
      <Proxy *>
      Order deny,allow
      Allow from all
      </Proxy>
      ProxyPassMatch ^/(.*\.cfm)$ http://testsite.railo:8080/$1
      ProxyPassReverse / http://testsite.railo:8080/
   </IfModule>

   #Deny access to admin except for local/portforwarded clients
   <Location /railo-context/>
      Order deny,allow
      Deny from all
      Allow from 127.0.0.1
   </Location>
</VirtualHost>

This tells apache to forward all requests for CFM files to the railo instance.

Finally restart apache and railo and you should be good to go.

sudo /opt/tomcat/bin/shutdown.sh
sudo /opt/tomcat/bin/startup.sh
sudo /etc/init.d/apache2 restart

Migrating CSS from Flex 3 to Flex 4

Having searched around for how to make CSS work when migrating to Flex 4 from Flex 3 and finding lots of incorrect namespace declarations I thought I'd blog this as a reminder to myself:

If you have a current Flex3 project and you are migrating to Flex4 you need to add the following lines at the top of your stylesheet.

This makes the default non-namespaced items in your stylesheet refer to the MX components. eg:

Button{fontSize:18;}
And to style up spark buttons you simply use:
s|Button{fontSize:18;}

Note there were lots of ones that I found that were wrong.

Do NOT use:

This info was sourced from the Flex SDK Wiki.

Flex 4 RSL's and how to not use them

Flex 4 allows and defaults to using Runtime Shared Libraries (RSL's).

These have advantages of making flash movies using them work very well, but they can also require more http requests the first time they are used, and are not good for application development with Northcode.

To turn them off you need to add the following compiler flag:

-static-link-runtime-shared-libraries=true

Thanks to Flex Butterflies and bugs for the info.

BlogCFC was created by Raymond Camden. This blog is running version 5.1.004.