1#!/usr/bin/perl 2# 3# Test using ApacheBench against an HTTP server with lots of idle clients 4# 5use IO::Socket; 6use Getopt::Long; 7 8use strict; 9use warnings; 10 11our $NCLIENT = 3000; 12our $BASELINE = 0; 13our @CLIENT; 14 15sub create_client { 16 my $socket = new IO::Socket::INET ( 17 PeerAddr => '127.0.0.1', 18 PeerPort => 8080, 19 Proto => 'tcp', 20 ) 21 or die $!; 22 push @CLIENT, $socket; 23} 24 25GetOptions("baseline" => \$BASELINE, "idle=i" => \$NCLIENT) or die; 26 27for (my $i = 0; $i < $NCLIENT; $i++) { 28 create_client(); 29} 30print "====> Created $NCLIENT idle connections <=====\n"; 31 32system "ab -n 5000 -c 500 http://localhost:8080/"; 33