Skip to content

Commit

Permalink
implement --max-keepalive-requests (issue miyagawa#124)
Browse files Browse the repository at this point in the history
  • Loading branch information
eserte committed Jul 4, 2017
1 parent 24febd7 commit 781e413
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/Starman/Server.pm
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,8 @@ sub process_request {
or die $!;
}

my $keepalive_requests = 0;

while ( $self->{client}->{keepalive} ) {
last if !$conn->connected;

Expand Down Expand Up @@ -322,6 +324,10 @@ sub process_request {
}
}

if (exists $self->{options}->{max_keepalive_requests}) {
last if ++$keepalive_requests >= $self->{options}->{max_keepalive_requests};
}

DEBUG && warn "[$$] Waiting on previous connection for keep-alive request...\n";

my $sel = IO::Select->new($conn);
Expand Down
10 changes: 10 additions & 0 deletions script/starman
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,16 @@ failover (see above).
Number of the requests to process per one worker process. Defaults to 1000.
Note that "requests" actually means "connections served by a worker".
In presence of Keep-alive a worker process can actually serve more
requests; this can only be limited with the
C<--max-keepalive-requests> option.
=item --max-keepalive-requests
Maximum number of Keep-alive requests served for a connection. By
default there's no limit.
=item --preload-app
This option lets Starman preload the specified PSGI application in the
Expand Down

0 comments on commit 781e413

Please sign in to comment.