Gossamer Forum
Home : General : Perl Programming :

problem with multithreaded web client

Quote Reply
problem with multithreaded web client
this is my first time playing with forked processes and this script starts having issues when I run more than 10 or 20 threads... if I run a high number of threads if one process has a problem then all of them die... i need to figure out either my problem or how to debug this kind of thing. also, is there a better way to be doing this? I am trying to make a load testing application to stress test servers in a QA environment.

------------------

#!perl.exe

use LWP;
use HTML::Parse;
use HTML::Element;
use HTTP::Request;
use Thread qw(async);
use strict;

printf "\n-------\n";

my @children;
for (1..4)
{
$children[$i] = async {
getIt();
};
}

for (my $i=0;$i<4;$i++)
{
$children[$i]->join();
}

sub getIt()
{
my $ua = LWP::UserAgent->new();
$ua->agent("MyApp/0.1 ");
my $url = 'http://web.pdx.edu/~jonw';
my $req = HTTP::Request->new(GET => $url);
my $res = $ua->request($req);
my $code = $res->code;
my $content = $res->content;
if ($res->is_error())
{
printf "%s\n", $res->status_line;
}
else
{
my $content = $res->content();
}
printf "$content\n-------\n";
}

Last edited by:

mozkill: Apr 18, 2003, 3:36 PM
Quote Reply
Re: [mozkill] problem with multithreaded web client In reply to
This may be a good alternative...

http://search.cpan.org/...arallel/UserAgent.pm

It certainly tested my spelling capabilities (I can never spell Parallel Wink)

Last edited by:

Paul: Apr 18, 2003, 3:45 PM
Quote Reply
Re: [Paul] problem with multithreaded web client In reply to
you absolutely rock! i didn't realize that class was available. thank you!

I seems though that there is not a release for 5.6.1? The PPM version of this module, called "ParallelUserAgent" wont install on 5.6.1 and so I assume that on windows XP that I will need to use Perl 5.8 or I may even need to use Windows 2K ? Can you tell me the OS/Perl Ver that you are using with this module?

Or, did you build this module using the make file? IF so, did you do it on windows and with what environment?

Last edited by:

mozkill: Apr 19, 2003, 11:13 AM
Quote Reply
Re: [mozkill] problem with multithreaded web client In reply to
I don't have it installed personally on my pc. Try this URL:

http://ppm.activestate.com/...arallelUserAgent.zip
Quote Reply
Re: [Paul] problem with multithreaded web client In reply to
Interesting. I was able to install it by hand. I just unzipped that file, placed the files in my Perl directory in their logical location beneath the "site" directory and it works I think. I was able to run this script without any errors:

use LWP::Parallel;
print "This is LWP::Parallel_$LWP::Parallel::VERSION\n";

I'll let you know what happens. Thanks for all your help. :-)

Last edited by:

mozkill: Apr 21, 2003, 11:29 AM