Update 1/27/07: MT 3.34 is out with improved FastCGI support and between that and some experience, I've tweaked my setup some. I need to write up a better set of instructions, but right now my computer is in for repairs and I'm not up to writing a lengthy entry on a borrowed computer right now. The main things that I've changed are that I'm now having LightTPD spawn only one dispatch process and I've added one important line to the dispatch script as follows:
Just inside the eval block right above the line that reads: while (my $q = new CGI::Fast) {
I've added in require MT;
and right above the line that reads: $app->init_request(CGIObject => $q) unless $app->{init_request};
I've added the line: MT->set_instance($app);
These changes are to more closely match how the bootstrap module handles starting up a script and adding that line seems to allow comments to be reliably published through FastCGI.
However I am still getting periodic out of memory errors when I do more than a couple of big actions in a row such as a rebuild a comment and another rebuild. That makes me worry about what will happen as the blog grows.
Original text below:
Since it seems to be a bit of a moving target (and just so I remember myself), I thought I'd share what I did in order to get my Movable Type installation running with LightTPD and FastCGI at TextDrive. Needless to say, your milage may vary, especially at other hosts (and really I'm not sure that any other host will let you make this setup).
Why did I do this and was it worth it?
If you want to skip the background and get straight to the step by step instructions skip to the extended entry.
Unfortunately the real answer is probably a not so high minded "because I could" or "to see if I could" but in general if there's a better way to do things, I like to at least try to take advantage of it. To be certain, I'm seeking to solve a problem that I don't suffer from all that much. The problem being that standard CGI is slow. Every request for the CGI program will cause the perl (in this case) script to be compiled and loaded into memory even if you just used the same program a few seconds ago. This means that the user waits and the server gets the load of repeatedly starting new processes. It's easy to see how a stateless protocol like http would encourage this, but it can suck, especially when your blog gets hammered by spammers (or users for that matter) generating a huge number of requests to the comment or trackback script in quick succession. Even in normal operation, it simply slows things down and is one reason some people may find Movable Type less appealing than blogging applications which take a different approach, such as using php. The "standard" approach for fixing this in recent years has been to compile a script interpreter into Apache via a module like mod_php, but for a number of reasons that I don't entirely understand, mod_perl is not as secure or common as mod_php. FastCGI seeks to remedy this problem by starting one or more persistent processes which start up once and handle requests for scripts, staying active between requests. Unfortunately, Apache's implementation of FastCGI isn't very good (again for reasons that I do not entirely understand), however LightTPD was designed with good FastCGI support built in. Some people may favor using LightTPD anyway, even for serving static content because it apparently scales much better than Apache for handling high levels of traffic without requiring unreasonable amounts of resources.
So... Was it worth it? Well, as I said, I have neither a high traffic site nor one that has so far attracted (much) spamming, but the second at least is inevitable with time, and who knows, I could see more traffic someday. The bottom line, though, is that where I see the most difference is in the responsiveness of the application, and there you really can tell the difference. You click and the new page pops open. To be sure, there are still delays sometimes, and it isn't as if the rebuilds have gone away, but I never, anymore, have to wait for a link to open longer than I would expect from any static website.
Disadvantages? Well, anytime you stray out of the standard or increase the complexity of your setup, you do risk something unforeseen going wrong. You should probably keep a bit of a closer eye on things set up this way than you would otherwise. At first I did have a couple of major ongoing complaints with my setup: If you want to avoid having the port number in all of your links to the Movable Type application, you will need to proxy through from Apache to LightTPD which, in my hands anyway, causes Movable Type to see all incoming connections to be from localhost, confusing the spam filters. Also, the proxy setup means that you can't adjust mod_security yourself (you'd have to file a ticket to get them to disable it or modify the rules for you). Because of these problems, I've scrapped the proxy setup and simply have links to the application go directly to my LightTPD port. I'm waiting to hear from anyone about whether this could be a bad idea for some reason, but I'm happy so far.
Update 12/10/06: Thanks to a comment from Brad Choate, I've now fixed the problem with Movable Type seeing the wrong IP address and so I am now using the proxying method instead of pointing directly to the LightTPD port, and I've described that setup below.
Ok, here's the goods. Read on for the detailed version of how I got things set up: