I am using Perl Dancer2 as the RESTful service framework with the basic setting (using command
dancer2 -a MyWeb::App
to generate template files and add "get" routes in the auto-generated MyWeb-App/lib/MyWeb/App.pm file). Recently I found out that when one request needs a long period of time to finish, the server is locked to only serve that request. For example
get '/' => sub {# simple request to redirect to a static page
template 'index'; #template directive Templates all go into the views/
};
get '/compute' => sub{
for (my $i=0;$i<1000000;$i++){
wait(1000); #simulate long computation time
}
return "Done!";
};
When firstly in one tab http://myhost.com/compute
is entered, in another tab the link http://myhost.com/
won't display anything until the previous /compute route finishes, which seems to me that only one connection is allowed at a time. The question is how to set up the Dancer2 server to allow multiple connections, i.e. the two tabs mentioned above can be run at the same time?
Many thanks!