Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

perrin (4270)

  (email not shown publicly)

Perrin is a contributor to various Perl-related projects like mod_perl, Template Toolkit, and Class::DBI. He is a frequent speaker at OSCON, YAPC, and ApacheCon, and a contributor to several perl-related books.

Journal of perrin (4270)

Thursday August 31, 2006
11:06 PM

HTTP Server Fever!

[ #30831 ]

Is it just me, or is everyone writing an HTTP server these days? After Apache 2 became solid, it looked like there wasn't much of interest left to do in the world of HTTP servers, and the field had been fully commodified. CPAN had a half dozen or so Perl HTTP servers, all of which were fine for entertainment but not useful for real sites. You'd hear some crank on Slashdot shouting about thttpd (I swear that wasn't me), but it didn't set the world on fire.

Then the single-threaded servers started showing up in earnest. A non-blocking I/O approach to networking is well-known to scale better than threads or processes, and it appealed to developers in a very primal way -- it's fast! Well, not so much fast, since you'd run out of bandwidth long before that mattered, but you could handle lots of open connections to slow clients without any trouble.

Lighttpd quickly became a star, especially in the PHP and Ruby worlds. (Why were Rails developers looking for a faster web server rather than trying to fix Ruby's performance problems? Probably because it's a much easier problem.)

Somewhere in there, Perlbal made the scene. It's a bit of a hodgepodge of features, having been developed to suit some particular in-house project needs, but an interesting sort of glue project to fill gaps in the Perl web app deployment story.

Some of the Rails guys then decided they didn't like FastCGI and would write their own HTTP server to replace it, called Mongrel. So far, the benchmarks I've seen make it look like performance has gotten worse compared to what they had with FastCGI, but it's still early so maybe they will improve that. They say they were doing it because the FastCGI implementations all had bugs, so maybe they don't care if it's slower anyway.

Meanwhile, people started popping up on the mod_perl list saying that they had built their own single-threaded servers. I usually ask people two things when they say this:

  • What will you do about DBI, and all of the other blocking network and file I/O calls that are the bread and butter of the average web app? Stalling your entire site while someone waits for a query is not going to work.
  • How is this better than running Perl on Lighttpd + FastCGI?

The only good answer I've heard to the first question so far is to ship the blocking stuff off to some separate persistent processes (e.g. mod_perl, PPerl, etc.) that you talk to over non-blocking I/O, and pick up the results when it's done. This is what Stas Bekman did with the single-threaded server he works on at MailChannels (for blocking spam). It's also what Matt Sergeant seems to be planning for his new single-threaded AxKit2 HTTP server.

Meanwhile, back at the Apache 2 camp, mod_proxy has picked up useful new features like basic load balancing and people are experimenting with hybrid threaded/non-blocking I/O process models.

It's good to see innovation happening. Sometimes I do wonder if people are chasing the right things. I find it pretty easy to make a screamingly fast web app with basic Apache and mod_perl these days, so maybe pushing things in a direction that makes development harder (as I think single-threaded programming will be for most people) is not the best move for all of us. High-performance has an undeniable allure though, especially for people like us who still have to convince managers that Perl is fast enough for a web site. (Duh. Maybe you've heard of Amazon?) I'll certainly be paying attention though, to see what Matt and everyone else cooks up.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • FWIW: not all Perl servers are single threaded: HTTP::Daemon::Threaded [] was recently loaded to CPAN. Its pretty green (simplistic session mgmt, no DBI connection pools - yet), and isn't really intended for large scale performance, but rather for simple integration into web-enabled apps. But it might be interesting to see how well it can scale (ie, how many threads can be managed).

    I'm currently using it to develop a debugger [] (very prelim view), hopefully that will shake out HTTP::D::T a bit more.

    BTW: does

    • I think Brian Mosely has left the building. He used to be on the mod_perl list, but we haven't heard from him in years. I'd steer clear of Servlet at this point.
  • One thing I find interesting is that the new web servers are being used because of bugs in the older ones. Lighttpd + FastCGI is popular partially because mod_fastcgi on Apache 2 has issues. Instead of fixing the bugs or using mod_fcgid, people switched platforms. And mod_ruby does exist but I don't know why people don't use it for Rubys on Rails.
    • The Ruby people pushing for Mongrel were fleeing Lighttpd and FastCGI, which they claim is buggy.
  • You've got a pretty big vested interest in Apache/mod_perl, and while I did previously, I don't any more. I have to be honest in that writing AxKit2 this way was mostly because I was curious as to how good it could be. I know pretty much for a fact that it'll be slower than mod_perl, because Apache2's connection handling and perl integration is very well built and designed.

    However now AxKit2 is built I find it much easier to hack on than mod_perl, and not just because I know the internals. Adding a new conf
    • Adding config stuff was pretty bad in mod_perl 1. It's supposedly easy in mod_perl 2, but I've never wanted to add a config directive so it's not something I pay attention to. I really don't use any of the Perl config stuff in mod_perl at all. It just doesn't appeal to me.

      Profiling, quick restarts -- well, they work for me in mod_perl. (This reminds me of working at a place that used IBM WebSphere, where restarting the dev tools to pick up a code change took 10 minutes! What a pig that thing was.)


      • I think partly people don't add custom config in mod_perl apps because they're hard (still non-trivial in mod_perl2 - that was one of my stumbling blocks in doing a straight AxKit port to mp2), and partly because they are satisfied with "PerlSetVar" which I never really liked as it didn't seem to cope with multivalues terribly well, and partly because none of the introductory docs cover them. I've tried to make sure my introductory docs jump right into them because they're terribly useful.

        Another option I'm