For example, server use subpress in controller:
#!/usr/bin/perl
use Mojo::Base -strict;
use Mojolicious::Lite;
use Mojo::IOLoop;
any '/' => sub {
my $c = shift->render_later;
Mojo::IOLoop->subprocess(
sub {
sleep 2;
},
sub {
$c->rendered(200);
});
};
app->start;
Client create many connections to server and on each connection server make
fork:
#!/usr/bin/perl
use Mojo::Base -strict;
use Mojo::IOLoop;
use Mojo::UserAgent;
my $d = Mojo::IOLoop->delay(sub { say 'finish' });
my @uas;
for (0 .. 800) {
push @uas, my $ua = Mojo::UserAgent->new;
$ua->get('http://127.0.0.1:3000' => $d->begin);
}
$d->wait;
So. server have many heavy processes.
If there was a pool of connections, then this would not be a problem.
понедельник, 29 августа 2016 г., 21:40:02 UTC+5 пользователь sri написал:
>
> What about to add pool of subprocesses? Pool would allow to use
>> subprocesses safely in controllers.
>>
>
> Please elaborate, what exactly makes the current approach unsafe?
>
> --
> sebastian
>
--
You received this message because you are subscribed to the Google Groups
"Mojolicious" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/mojolicious.
For more options, visit https://groups.google.com/d/optout.