Bill Clementson's Blog

Bits and pieces (mostly Lisp-related) that I collect from the ether.

December 2005
Sun Mon Tue Wed Thu Fri Sat
1 2 3
4 5 6 7 8 9 10
11 12 13 14 15 16 17
18 19 20 21 22 23 24
25 26 27 28 29 30 31
Nov  Jan

Using a Lisp Web Server Behind Apache

Monday, December 19, 2005

I've written in the past about Lisp web servers (see here, here, here, here, here, here). Two common options for running Lisp web servers are:

  1. Running standalone (e.g. - using AllegroServe or Araneida by itself): This can be convenient when your web serving requirements are fairly straight-forward and/or you do not have a company standard that you need to conform to.
  2. Running behind Apache (e.g. - using Apache for many web server functions but using the Lisp web server to serve up Lisp dynamic content): This is a useful approach when there is either a company standard of Apache that you need to conform to or if there are certain standard Apache modules that you would like to be able to use. This can be done using either mod_lisp or mod_proxy to redirect requests to the Lisp web server. You might question whether the requirement for Apache is really that "hard" of a requirement. Well, according to this Netcraft survey, about 70% of surveyed sites on the web use Apache. There can obviously be advantages in not doing the same thing as everyone else; however, there are also lots of good reasons why companies choose to use Apache. Some Lisp web server frameworks (e.g. - UncommonWeb and TBNL) provide (and document) this capability; however, others only allude to it in their documentation.
Doing #1 with many of the Lisp web servers is very easy for a beginner to do as the standard documentation that comes with Araneida or AllegroServe describes the necessary setup steps that one needs to do to get things going. However, there is little information available on doing #2. Recently, I came across this weblog entry by Dan Knapp which points to a web page that describes (step-by-step) how to use the standard mod_proxy and mod_rewrite Apache modules to do exactly this. Dan describes the rationale for using Apache:
"There are several webservers implemented entirely in Lisp. You may be excited about the prospect of using them. But, if you've tried using them for part of a large site, you may have realized that Apache does certain things better, and it would be nice if you could somehow use Lisp for only part of the site. Or, you may be advocating that Lisp be used for a part of your corporate website, but the company understandably does not want to redo the entire site to use a Lisp server. Perhaps it's just easier to sell people on the idea of Lisp if it fits in with other things instead of trying to replace everything.

One solution is to run two webservers: the ordinary Apache one, and the special Lisp one. Anytime Apache receives a request that should be handled by Lisp, it opens a connection to the Lisp webserver so that it can be done. Here, I show you how to create exactly this setup, using the simple rule that any file ending in the extension .lisp will be handled by Lisp."
So, with the explanations on Dan's page, it is relatively straight-forward to get a Lisp web server running behind Apache using mod_proxy. Since mod_proxy comes with Apache, one might question whether it would be worthwhile to use Marc Battyani's mod_lisp at all since it does not come standard with Apache and it seems to provide similar functionality to mod_proxy. Well, there are actually some good reasons to use mod_lisp instead of mod_proxy for serving up Lisp content (slightly edited):
"There are several reasons why mod_lisp is faster than mod_proxy and generally than a standalone lisp server in real world applications:

The most important point for the speed is that mod_lisp keeps the Apache => Lisp socket open.

Most Lisp implementation don't use native threads or don't allow more than one thread to be active. So using Apache as a front-end is more efficient if there are more than one processor (or an HT one)

Apache can serve the static content thus leaving more Lisp CPU time to process application logic."
In a separate thread (to counter a contention by Brian Mastenbrook that a stand-alone Araneida web server is preferable to a mod_lisp-based solution), Marc provides some additional reasons for using mod_lisp+Apache rather than just a stand-alone Lisp web server (slightly edited):
"> result is that Araneida is nearly unmaintained, while worse solutions
> like mod_lisp and paserve are more actively maintained.

I beg to differ here about mod_lisp being a worse solution than Araneida. First, I think you don't understand what mod_lisp is really about: mod_lisp is only an Apache module and there is no Lisp functionality to compare with Araneida. So if you want to compare a mod_lisp based system to Araneida you have to pick a Lisp framework based on mod_lisp.

So now if you compare Araneida to the mod_lisp based solution you have:

Apache/mod_proxy + Araneida

vs

Apache/mod_lisp + TBNL
Apache/mod_lisp + UCW
Apache/mod_lisp + my own framework

Now on what points are the mod_lisp based solutions worse?

mod_lisp is faster than mod_proxy
mod_lisp is well integrated into Apache
mod_lisp is corporate compatible
mod_lisp is maintained and has an active users base
mod_lisp is very stable and mature

And the 3 frameworks I named all have more functionalities, are at a much higher level and are actively evolving.

The HTTP processing is a boring problem which has been solved for years now. These days the interesting stuff is in the framework/application layers. The current topics are on subjects like continuations or not for instance. Pascal Costanza is organizing a debate next Monday between Avi Bryant and me where we will present our frameworks and I can assure you that nobody will care and talk about the HTTP layers. Everybody interested in the subject is invited to participate."
In fact the entire thread (of which the above quote is just part of) is an interesting one to read as many of the different Lisp web server alternatives are discussed and contrasted. Incidentally, the debate between Avi Bryant and Marc Battyani (mentioned at the end of the above quote) was the "Web Application Frameworks in Smalltalk and Common Lisp" debate in Brussels in April 2005. Marc and Avi actually had more to agree about then disagree about during the debate as both of their frameworks make optimal and innovative use of dynamic web content. Avi has material about his Smalltalk-based Seaside web application framework available on his web site (and he has presented to the Vancouver Lisp Users Group as well!). Marc's CL-based web application framework isn't publicly available (and, unfortunately, he hasn't "yet" presented to the Vancouver Lisp Users Group!); however, he discusses the concepts underlying his framework in the Powerpoint presentation that he gave at the Brussels debate as well as in his ILC2002 paper. There's also a torrent available of Marc's ILC2002 talk. Some of the material in Marc's talk/paper also discusses some of the rationale behind using a solution based on mod_lisp+Apache.

For the time being, if you want to use a Lisp web server with mod_lisp+Apache, it is easiest to use either Edi Weitz's TBNL or Marco Baringer's UCW (although some people have used AllegroServe and Araneida behind mod_lisp+Apache). If you want to try to "roll your own", there are a couple of tutorials (the last two that are on this weblog posting of mine describe some of the steps necessary to get things setup correctly using mod_lisp+Apache) as well as the mod_lisp documentation and example code to help you get started.

emacs Copyright © 2005 by Bill Clementson