# if( threads::list( threads::running ) >= 100 ) {
# sendResponse("Session rejected. Too many sessions currently r
+unning.\n", 101, $client); #just decided 101 should be the retry retu
+rn code, no reason really
# # tprint( "Session request by " . $client->sockhost() . " rej
+ected" ); #disabled because it was flodding the log
# $client->shutdown(2);
# $client->close;
# }else
Tweaked the client (rx,pl) to run many commands in loop and do so from multiple threads: our $T //= 1000;
our $R //= 1000;
my @threads;
for my $t ( 0 .. $T ){
push @threads, async {
for my $r ( 1 .. $R ) {
print "Client:$t sending command: $r\n";
my $server;
my $rc;
my $response;
while(1){
$server = IO::Socket::INET->new(
Proto => "tcp",
PeerAddr => $address,
PeerPort => $port,
);
unless (defined($server)){print "Unable to connect to
+RXD; [$! / $^E\n";}
$server->autoflush(1);
sendCommand( $server );
($response, $rc) = receiveResponse( $server );
if($rc == 101){
shutdown($server, 2);
close $server;
my $random = 1 + rand(10);
# select(undef, undef, undef, $random);
next;
}
else{last;}
}
debug("Closing connection");
shutdown($server, 2);
close $server;
};
};
}
$_->join for @threads;
With 5.16.1, this falls in a heap with 1 thread after just a few seconds. The same "invalid handle" stuff as you've been seeing.
With 5.10.1, I ran the above with those numbers -- 1000 concurrent clients, each running 1000 commands (the simple dir /s) and it ran to completion (after 1,000,000 commands served :), without errors in a little over 1 1/2 hours. And that's with 3 cores running the server and 1 core running the clients. Peak memory usage for the server was around 1.5 GB.
Again, I really cannot stress enough how thankful I am for all your help debugging. Could not have gotten this far without you.
YW. I learn almost as much from each of these real-world uses as the people I'm helping do.
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP Neil Armstrong
|