嗨我建立了一個非常簡單的HTTP服務器,只做POE模塊的壓力測試。嗯,IO ::異步甚至不能處理10k連接?
以下是我測試過它:
for x in {1..10000}; do
curl xxxxx:12342 --retry-delay 5 --retry 3 -d randombytes$x
done
當我這樣做,我看到多個「連接重置」的對等消息,所以這個10K的連接我失去了總共約1200請求。
反正有改善它的表現嗎?在同一臺服務器上測試nginx,在此期間沒有更改內核參數,根本沒有連接重置消息。
編輯
我已經增加最多的fileno /每用戶最大的fileno,前者fs.file-max = 3246455
,而後者是10240
附源代碼:
use strict;
use warnings;
use feature 'say';
use Net::Async::HTTP::Server;
use IO::Async::Loop;
use HTTP::Request;
use HTTP::Response;
use Data::Dumper;
my $loop = IO::Async::Loop->new();
my $httpserver = Net::Async::HTTP::Server->new(
on_request => sub {
my ($self, $req) = @_;
my ($code, $result) = (200, "It works\n");
my $response = HTTP::Response->new ($code);
$response->add_content ($result);
$response->content_type ("application/json");
$response->content_length (length $response->content);
$req->respond($response);
},
);
$loop->add($httpserver);
$httpserver->listen(
addr => { family => "inet", socktype => "stream", port => 8080 },
on_listen_error => sub { die "Cannot listen - $_[-1]\n" },
);
say 'Listening normally on ', 8080;
$loop->run;
標籤說POE,說明和代碼說IO :: Async。我會重複 – LeoNerd
@LeoNerd嗯我只是沒有找到io :: async標籤,謝謝 – daisy