Subject: Re: Web applications and threading
From: rpw3@rpw3.org (Rob Warnock)
Date: Mon, 18 Apr 2005 03:12:43 -0500
Newsgroups: comp.lang.lisp
Message-ID: <xf6dnf6XNLlm9v7fRVn-oA@speakeasy.net>
<steve.huffman@gmail.com> wrote:
+---------------
| I'd like to write a web application based in Lisp. I'm planning on
| using TBNL with either apache + mod_lisp or areineda. I am wondering
| how important it is that my Lisp implmentation have threading? On my
| Mac I can use OpenMCL for development, but I'd like to deploy the app
| in FreeBSD or Linux, using SBCL or CMUCL.
| 
| Does anyone have experience working in a situation like this?
+---------------

I didn't use TBNL, but I did develop a small production application
using Apache + CMUCL + PostgreSQL, with a "mod_lisp"-like interface[1]
from Apache to CMUCL, HTOUT <http://www.cliki.net/htout> as the HTML
generation tool[2], and PG <http://www.cliki.net/Pg> to talk to PostgreSQL.

My app predated "cl-modlisp" <http://www.cliki.net/cl-modlisp>, so I
wrote my own application server front-end code, which fires up a new
CMUCL thread[3] for each Apache request, mainly to prevent a browser
that makes a large request via a really slow network cornection from
blocking later requests from browsers on much-faster lines.

All in all, I've been very happy with it!! [4]


-Rob

[1] It's a tiny C-based CGI program that opens a Unix-domain socket to
    the CMUCL-based server. I carefully made the socket protocol be a
    subset of the "mod_lisp" protocol, so I could change to using real
    "mod_lisp" later if performance became as issue. [It hasn't yet.]

[2] CL-WHO <http://www.cliki.net/cl-who> would probably have worked
    just as well. I just happened to start with HTOUT [which was
    available earlier, IIRC].

[3] By "thread", here, I mean a within-a-single-Unix-process coroutine
    or "green thread", as it's sometimes called -- what the documentation
    of the CMUCL "MP:" package confusingly refers to a "process".

[4] Well, once I realized that you really, *REALLY* want to call
    MP::STARTUP-IDLE-AND-TOP-LEVEL-LOOPS in the top-level REPL (but
    *after* loading all the pieces of the app) so the whole world
    doesn't stop just because you do a blocking read in the REPL...  ;-}
    [It's also speeds up the threads' context switching.]

-----
Rob Warnock			<rpw3@rpw3.org>
627 26th Avenue			<URL:http://rpw3.org/>
San Mateo, CA 94403		(650)572-2607