Another very simple way to fork processes using LWP is by using
Parallel::ForkManager. It's shockingly simple to make your code parallel in this way, here's how you could apply it to the loop in your code:
use Parallel::ForkManager
my $max_forks = 20;
my $forkmanager = Parallel::ForkManager->new( $max_forks );
for ($count = 0; $count <= $max; $count++){
$forkmanager->start and next;
my $content;
unless (defined ($content = get $URL)) {
die "could not get $URL\n";
}
if ($content =~ /Test1/i) {
print ".";
}
elsif ($content =~ /Test2/i) {
print "Fetched page from Server2 \n";
$count++;
&result;
}
else { print "Page not retreived \n" };
$forkmanager->finish;
}
$forkmanager->wait_all_children;
This testing is also probably dependent on the maximum number of clients you support, this may not be high enough to stress your gateway either. Check on the MaxClients parameter in your httpd.conf for more information. Depending on what you're testing, it may be fruitful to use LWP to download larger files rather than making more requests.
Best of luck. :)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.