user3099352
user3099352

Reputation: 1

How to run a cgi script independently for concurrent connections

I'm just starting out with web development. For apache server 2.4, with mpm_prefork and cgi enabled.

As a cgi application, I've the following perl script:

#!/usr/bin/perl
local $| = 1;
print "Content-type: text/html\n\n";

$r = int(rand(1000000));
for (my $i = 0; $i < 10; $i++) {
       print "$i $r\n";
       sleep(2);
}

If I run this cgi script in two browser tabs (localhost/cgi-bin/sleep.pl), then the second one starts only after the first one is complete.

I'd like to able to run these concurrently. Is there an apache configuration setting for this or do I have to fork within the perl script itself?

thanks,

Upvotes: 0

Views: 232

Answers (1)

Armali
Armali

Reputation: 19375

I'm inclined to think that your browser is delaying the second call until the first one is done, since you are requesting the same resource. Maybe try from a different browser (IE, Chrome, Firefox) instead of just a separate tab. – Tim A

Upvotes: 1

Related Questions