http://qs321.pair.com?node_id=11117756


in reply to Re: Recommend an asynchronous HTTP server CPAN modules?
in thread Recommend an asynchronous HTTP server CPAN modules?

Warning: Twiggy is asynchronous in the sense that it runs on top of an AnyEvent event loop. This means that all code in the request handlers has to be written in an asynchronous, callback style. If any part of that code ever blocks, the entire server becomes unresponsive. This is especially tricky if the request handlers have to do database operations; I only have direct experience with PostgreSQL, which has async support, but with severe limitations. For example, you have to implement connection pooling yourself if you ever want to serve more than one database operations at the same time.

OTOH, I second the recommendation of Starman. By default, it works as a pre-forked server with a fixed number of workers (it even reaps and restarts its workers after they've served a number of requests), but it can be coaxed to adjust the number of workers between a configurable minimum and maximum in response to the server traffic (these options are not mentioned in Starman's docs, you have to dig down into Net::Server::PreFork, on which it is based on).

Starman is also "easier" in the sense that if you have some simple, naive, synchronous server code that works with plackup's default server, it will work with Starman too with no changes.

  • Comment on Re^2: Recommend an asynchronous HTTP server CPAN modules?