jonathanpeppers jonathanpeppers - 4 months ago 7x
Perl Question

Perl Mojolicious - How to make it handle multiple connections at once?

I setup a quick Mojolicious server like this:

use Mojolicious::Lite;

get '/' => sub {
my $self = shift;

sleep 5; #sleep here, I'm testing multiple connections at once

$self->render_text('Hello World!');


I then start it with:
perl daemon --listen=

Problem is, if I run this command concurrently:

It seems to only use 1 thread for requests, because if I make multiple requests at once, they can take much longer than 5 seconds. It's as if they are all queued up.

Am I missing something here? I'm wanting to use Mojolicous, but only if it can handle more than one client at a time.


mojo daemon is a standalone HTTP server meant for development use, not production, and it only runs a single thread. For production you would want to either use the fastcgi option and a FastCGI-supporting webserver, or install a nice PSGI-compatible server like Starman or Starlet or Plack::Handler::FCGI or Fastpass and then do

plackup -s Starman --port 3000