in reply to Re^14: PANIC: underlying join failed threded tcp server
in thread PANIC: underlying join failed threded tcp server
HEY! Got the server working by putting some of Thread::Queue into my code, and now it seems to be running like a champ. If you'd like to see the code let me know, but I'm guessing you have a fair idea of how its working. Ran 200k commands in 2 hours without a hiccup.
Cool. (Yes. I would really like to see the code. You have my email id.)
And that is really interesting that threads got messed up. I'll definitely try downgrading perl and testing it out but as it is no longer a time critical thing, and more a matter of interest, I probably wont get to it until next week.
I took your latest code -- stripped out the defensive stuff out of rxd.pl:
# 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.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^16: PANIC: underlying join failed threded tcp server
by rmahin (Scribe) on Nov 16, 2012 at 00:21 UTC |