I have this simple PSGI application (app.psgi).
use strict;
use warnings;
my $app = sub {
my $mem = `ps -o rss= -p $$`;
$mem =~ s/^\s*|\s*$//gs;
return [ 200, [ 'Content-Type' => 'text/text' ], [ $mem ]];
};
I was asked 1000 times and got increased memory usage. Depending on how the server was started, received:
plackup - memory usage increases from the first 3 requests and remains constant for the next 997 requests
plackup -r - memory usage randomly rises (not for every request) by 4k.
starman - as described above, memory usage is randomly increased by 4k, but at a lower speed
The question arises:
- ? , ( starman), , . (, , , -- 100), .
- - ?
- - script :
use strict;
use warnings;
use LWP::UserAgent;
my $ua = LWP::UserAgent->new;
my $req = HTTP::Request->new(GET => 'http://localhost:5000');
my $old_mem = 0;
print "req#\tmem\n";
foreach my $i (1..1000) {
my $res = $ua->request($req);
(my $mem = $res->content) =~ s/\D//g;
next if( $mem == $old_mem );
print "$i\t$mem\n";
$old_mem = $mem;
}
:
plackup plackup -r starman
req# mem req# mem req# mem
1 7780 1 3924 1 3280
2 7800 2 4296 5 3728
3 7804 3 4304 8 3280
... ...
... deleted ... deleted
... ...
839 4596 994 3912
866 4600 998 3908
962 4604 1000 3912
,
plackup ?plackup -r - 4k (. ) -starman - , 5 (3280- > 3912)
:
Plack is up to date. (0.9979)
Starman is up to date. (0.2010)
This is perl 5, version 12, subversion 3 (v5.12.3) built for darwin-thread-multi-2level