Skip to content

Commit

Permalink
100 keep-alive requests are more common
Browse files Browse the repository at this point in the history
  • Loading branch information
kraih committed Mar 3, 2016
1 parent 660bd60 commit ccc5931
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions Changes
Expand Up @@ -7,6 +7,7 @@
- Deprecated Mojo::Server::Daemon::multi_accept.
- Added single_accept option to Mojo::IOLoop::Server::listen.
- Added single_accept parameter to Mojo::Server::Daemon::listen.
- Increased default max_requests from 25 to 100 in Mojo::Server::Daemon.
- Improved performance of many Mojo::Util functions slightly.
- Fixed default value bug in val method of Mojo::DOM.

Expand Down
6 changes: 3 additions & 3 deletions lib/Mojo/Server/Daemon.pm
Expand Up @@ -16,7 +16,7 @@ has [qw(backlog max_clients silent)];
has inactivity_timeout => sub { $ENV{MOJO_INACTIVITY_TIMEOUT} // 15 };
has ioloop => sub { Mojo::IOLoop->singleton };
has listen => sub { [split ',', $ENV{MOJO_LISTEN} || 'http://*:3000'] };
has max_requests => 25;
has max_requests => 100;

sub DESTROY {
return if Mojo::Util::_global_destruction();
Expand Down Expand Up @@ -447,9 +447,9 @@ to L<Mojo::IOLoop/"max_connections">.
=head2 max_requests
my $max = $daemon->max_requests;
$daemon = $daemon->max_requests(100);
$daemon = $daemon->max_requests(250);
Maximum number of keep-alive requests per connection, defaults to C<25>.
Maximum number of keep-alive requests per connection, defaults to C<100>.
=head2 silent
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Command/daemon.pm
Expand Up @@ -61,7 +61,7 @@ Mojolicious::Command::daemon - Daemon command
defaults to the value of
MOJO_REVERSE_PROXY
-r, --requests <number> Maximum number of requests per
keep-alive connection, defaults to 25
keep-alive connection, defaults to 100
=head1 DESCRIPTION
Expand Down
2 changes: 1 addition & 1 deletion lib/Mojolicious/Command/prefork.pm
Expand Up @@ -75,7 +75,7 @@ Mojolicious::Command::prefork - Prefork command
defaults to the value of
MOJO_REVERSE_PROXY
-r, --requests <number> Maximum number of requests per
keep-alive connection, defaults to 25
keep-alive connection, defaults to 100
-w, --workers <number> Number of workers, defaults to 4
=head1 DESCRIPTION
Expand Down
18 changes: 18 additions & 0 deletions t/mojo/daemon.t
Expand Up @@ -306,6 +306,24 @@ $loop->start;
ok $accepting[0], 'accepting connections';
ok !$accepting[1], 'connection limit reached';

# Request limit
$daemon = Mojo::Server::Daemon->new(
app => $app,
listen => ['http://127.0.0.1'],
silent => 1
)->start;
$port = Mojo::IOLoop->acceptor($daemon->acceptors->[0])->port;
is $daemon->max_requests, 100, 'right value';
is $daemon->max_requests(2)->max_requests, 2, 'right value';
$tx = $ua->get("http://127.0.0.1:$port/keep_alive/1");
ok $tx->keep_alive, 'will be kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Whatever!', 'right content';
$tx = $ua->get("http://127.0.0.1:$port/keep_alive/1");
ok !$tx->keep_alive, 'will not be kept alive';
is $tx->res->code, 200, 'right status';
is $tx->res->body, 'Whatever!', 'right content';

# Abstract methods
eval { Mojo::Server->run };
like $@, qr/Method "run" not implemented by subclass/, 'right error';
Expand Down

0 comments on commit ccc5931

Please sign in to comment.