Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by kikuchiyo (Friar)
on Jun 06, 2020 at 11:23 UTC ( #11117756=note: print w/replies, xml ) Need Help??


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?

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11117756]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2022-08-18 02:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?