barathbr has asked for the wisdom of the Perl Monks concerning the following question:
Hello Folks,
My objective is to stress test a load balanced web server. I wrote a simple script using lwp::simple. The script in its current form is fetching the page. However, since it is initiating the connections seqentially I am actually not stressing the gateway. Could somebody point me in the right direction on how to go about spawning multiple instances. Code snippets would be really really appreciated.
Thanks a lot The current version is pasted below:
My objective is to stress test a load balanced web server. I wrote a simple script using lwp::simple. The script in its current form is fetching the page. However, since it is initiating the connections seqentially I am actually not stressing the gateway. Could somebody point me in the right direction on how to go about spawning multiple instances. Code snippets would be really really appreciated.
Thanks a lot The current version is pasted below:
use LWP::Simple; use strict; my ($count, $max, $URL); unless (defined ($URL = shift)) { print "\n\nEnter the site address which you would like to access: +"; chomp($URL = <STDIN>); } $URL = "http://" . "$URL"; print "Site address is $URL \n"; unless (defined ($max = shift)) { print "Enter the number of times to hit the site: "; chomp($max = <STDIN>); } for ($count = 0; $count <= $max; $count++){ my $content; unless (defined ($content = get $URL)) { die "could not get $URL\n"; } if ($content =~ /Test1</font>/i) { print "."; } elsif ($content =~ /Test2</font>/i) { print "Fetched page from Server2 \n"; $count++; &result; } else { print "Page not retreived \n" } } sub result { print "page retrieved after $count tries \n"; exit; }
Edited by Chady -- replaced <pre> tags with <code> tags
Back to
Seekers of Perl Wisdom