NOTE: This paper was written in 1997 and last updated in June 1998. It is now woefully out of date, and should not be relied on. I might write an update some time...

Relative Performance of some Dynamic Web Technologies

Simon Brooke

Introduction

Some time ago, I posted some performance testing of the Apache module mod_java, and suggested that given the poor performance we should not consider deploying server side Java yet. John Robinson pointed out that there were other, better implementations of server-side java for Apache, and I've now done some further comparisons using the JServ module, now approved by the Apache project.

Versions:

Timings:

All runs timed using lynx version 2.6 in 'dump' mode and averaged over 25 fetches. Both server and client ran on the same machine, an i486dx2/100 running linux 2.0.27, thus reducing error due to varying network propagation conditions.

Static file, using 'file:' URL: 0.69 seconds
Static file, requested from Apache: 0.78 seconds
Complex PHP/FI file, no database access: 1.15 seconds
Simple PHP/FI form, one database query: 1.64 seconds
HelloWorldServlet, mod_java, large VM: 6.40 seconds
HelloWorldServlet, mod_java, 'ns' VM: 6.01 seconds
Servlet form, mod_java, one database query: 8.02 seconds
HelloWorldServlet, jserv 0.9.9: 0.94 seconds
SnoopServlet, jserv 0.9.9: 1.61 seconds
Servlet form, jserv 0.9.9, one database query: 1.26 seconds
Same query executed at psql command line: 0.09 seconds
Bourne shell CGI script, test-cgi 1.02 seconds
Perl shell CGI script, printenv 1.46 seconds
Compiled C CGI script, test.cgi, stripped 0.93 seconds

Conclusions:

Comparison of different languages

It's interesting to note the results for SnoopServlet, test.cgi, testcgi, and printenv, which I find completely counterintuitive. These four scripts all do much the same thing, namely print out the environment passed to them. None of them was written as a benchmark, so this comparison may be a little unfair. SnoopServlet, the Java contender, is slowest at 1.61 seconds, even with the best available Java server module. Next worst is Perl, at 1.46 seconds. This again may be slightly unfair, as it would probably be faster to run this with mod_perl. Best is the compiled C CGI, test.cgi at just under a second. But second by only a whisker is a Bourne shell script!

It would be an interesting project to take the same piece of moderately complex functionality and code it in each of these languages, to see how this affected the outcome. Certainly some of the 'win' of Bourne Again shell over Perl, and of the compiled C CGI over either, lies in executable size:

[simon@caleddon examples]$ ls -l `which perl`
-rwxr-xr-x   2 root     root       401200 Dec  5  1996 /usr/bin/perl
[simon@caleddon examples]$ ls -l `which bash`
-rwxr-xr-x   1 root     root       299296 Nov  2  1995 /bin/bash
[simon@caleddon examples]$ ls -l test.cgi
-rwxrwxr-x   1 simon    simon       13336 Mar 11 13:35 test.cgi  

More complex functionality would blur this effect, giving more emphasis to the actual performance of the language.

Comparison of different Java servlet systems

JServ offers performance similar to or better than PHP/FI, in my experience one of the better performing server-side scripting languages. This is in a sense good news in as much as servlets offer far better portability and intellectual property safety, and Java is a better engineered language than PHP/FI.

The serious performance hit in mod_java lies in the invokation of a new instance of the java virtual machine to service each servlet request. JServ maintains a pool of java virtual machines, and if a servlet is already loaded by a VM it will be reused.

Example code

My servlet forms library is at ftp://ftp.ibsc.co.uk/pub/htform.tgz . It is posted as much for comment and criticism as for anything else, at least for now! All comments gratefully received.

Simon Brooke

give me feedback on this page // show previous feedback on this page