Lua and the web: an overview 2008.03.15
Posted by nathany in Lua.Tags: Lua, webserver, Apache, Wiki, Kepler
trackback
Lua is among the top 20 most popular programming languages, according to the TIOBE Programming Community index. Lua is also faster and has a smaller memory footprint than other interpreted scripting languages (compare with Ruby, Python, PHP and JavaScript SpiderMonkey).
We haven’t heard a lot about Lua on the web, even though
there are a number of developers working with Lua on the server-side. Lets take a brief look.
The Kepler Project
Kepler is a “web development platform” named after astronomer Johannes Kepler. It looks to be the most ambitious project of the bunch. Kepler is written as a number of modules that fit together, and includes its’ own web server named Xavante.
There is also an endeavor to build WSAPI, in similar fashion to
Python’s WSGI interface, that support pretty much any web server and configuration (CGI, FastCGI, SCGI, etc, etc.)
Nanoki
When I joined to Kepler mailing list, “Petite Abeille” was the first person to respond. He has been developing a Wiki called Nanoki.
However, it is not built on top of Kepler. Instead there is a small built-in web server or will run atop the Unix tcp command. All the source code is released under a MIT license, and is instructive in building a light, focussed web application vs. the broad scope of Kepler.
mod_wombat
Brian McCallister spear-headed a project to embed Lua in an Apache HTTP Server module. Going through Brian’s slides is quite inspiring as to just how good a fit this is. Apache does all the heavy-lifting, such as providing a fully multi-threaded “worker MPM” (multi-processing module) and a portable runtime (APR) environment. Lua is a thread-safe language, with “share-nothing” Lua states, so it fits right in and is super-efficient.
Skimming through The Apache Modules Book is even more inspiring, as you can see the potential of mod_wombat if it took advantage of Apache’s database connection pooling (DBD) and the various other facilities of Apache HTTP Server.
Wombat is still a little rough around the edges, but you can find the Apache-licensed source code at:
http://svn.apache.org/repos/asf/httpd/mod_wombat/trunk.

I now use lighttpd with magnet.c from http://jan.kneschke.de/projects/lua and wsapi.fastcgi from wsapi. I tried mod_wombat before but didn’t have much success because I had troubles with the way it handles cache and the environment is wrong in my opinion (PATH_INFO, SCRIPTNAME are messed up for example). Furthermore, it unfortunately doesn’t seem to be very actively maintained despite being so promising.
Now I prefer to rely on WSAPI and eventually write a connector if I change of SAPI (from fastcgi to mod_wombat for example).
Bertrand,
mod_wombat exposes the httpd constructs directly, not CGI derivitives. A CGI-alike could be built on top, though.