# winner! # threads + Furl::HTTP with 10 threads -> 95mbps at 55% cpu # I also tested fork, which was the same, # but threads seemed cleaner use strict; use warnings; use threads; use threads::shared; use Furl; use Perl::Unsafe::Signals; my $quit : shared = 0; sub ctrlc { $quit = 1; } $SIG{INT} = \&ctrlc; my @urls : shared = ; my $numthreads = $ARGV[0]; print "num threads: $numthreads, pid: $$\n"; sub fetch { my $tid = shift; my $furl = Furl::HTTP->new(agent => 'Furl/0.31',timeout => 10); while(!$quit) { my $url = $urls[int(rand(int(@urls)))]; chomp $url; #print "start $tid: $url\n"; my ($ver, $code, $msg, $headers, $body) = $furl->get($url); my $size = length $body; #print "finish $tid: $url, $size bytes\n"; } } my @threads; for(my $i = 0; $i < $numthreads; ++$i) { my $thread = threads->create(\&fetch,$i); push(@threads, $thread); } UNSAFE_SIGNALS { foreach (@threads) { $_->join(); } } __DATA__ urls...