in reply to Recommend an asynchronous HTTP server CPAN modules?

I have recently been experimenting with Twiggy which is asynchronous by design. It has been surprisingly straightforward to use but although I have deployed it in some public-facing roles, none of those are high-volume or mission-critical so don't consider it battle tested by me.

Are there any other mature ones

Twiggy is mature in the sense that it's been around for a decade but hasn't seen a release in 5 years. Then again, it probably hasn't needed one. Given your description of the task it sounds like a good fit but YMMV, of course. Worth a look at least.

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

Replies are listed 'Best First'.
Re^2: Recommend an asynchronous HTTP server CPAN modules?
by kikuchiyo (Hermit) on Jun 06, 2020 at 11:23 UTC

    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.