Stress-Testing CGI in Parallel
By Randal L. Schwartz
Last month's column showed my first use of the LWP::Parallel::UserAgent -- a way of sending out multiple requests in the same process to be satisfied concurrently. This time, let's look at another use of the same package to stress-test a CGI script. If you haven't installed the Parallel User Agent, you'll find it in the CPAN. (The CPAN can be found at cpan.perl.org, among other places.) You'll also need to install the LWP package, also found in the CPAN.
As a practical test target, I decided to beat up on my Eliza bot script from a few columns ago (see "Programming with Perl," Web Techniques, April 1998). In fact, this was a good practical test to ensure that multiple users would have the right information, and that the program would work correctly no matter how fast the requests came in. I was hitting between 2 and 4 requests per second with this test harness on a moderate-speed SPARCstation, much faster than I could hit the submit button on my browser.
Request for Success
The program that repeatedly connects to the Eliza script is presented in
Listing One.
Line 1 begins most of the Perl programs I write, giving the path to my Perl (bin) directory and turning on warnings.