Prefork-MPM not handing out simultaneous requests to separate
am 31.01.2008 21:09:56 von urcabrazI might be missing something, but the pre-fork MPM doesn't behave as
I'd expect when faced with multiple long-running requests. (Apache +
mod_perl2.)
I'm running prefork-MPM and see that HTTP requests apparently aren't
farmed out to worker 'httpd' processes like I'd expected.
I'm using the stock 'httpd' from Fedora 8, with 'httpd -V':
[root@fullhouse pg_log]# httpd -V
Server version: Apache/2.2.6 (Unix)
Server built: Sep 18 2007 03:54:41
Server's Module Magic Number: 20051115:5
Server loaded: APR 1.2.11, APR-Util 1.2.10
Compiled using: APR 1.2.11, APR-Util 1.2.10
Architecture: 32-bit
Server MPM: Prefork
threaded: no
forked: yes (variable process count)
Here is the prefork configuration in httpd.conf:
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
After starting 'httpd' I see these relevant httpd processes:
[telosdev@fullhouse thefifth_web]$ pstree -pn | grep httpd
|-httpd(2828)-+-httpd(2830)
| |-httpd(2831)
| |-httpd(2832)
| |-httpd(2833)
| |-httpd(2834)
| |-httpd(2835)
| |-httpd(2836)
| `-httpd(2837)
I have mod_perl2 and a 'startup.pl' that loads all expected mod_perl2/
Apache2 Perl modules. I have a handler defined like this:
sub handler {
my $r = shift;
# Print junk to begin
$r->content_type('text/plain');
print("this is content from the EgModule01.pm module\n\n");
# Sleep a little for testing
sleep(10); # <-------- the 'httpd' prefork
server as configured should be able to handle
# 2 requests with this handler
simultaneously in separate processes,
# even with this 10-second delay,
right?
# Are we done? Yes!
printf("\nDone at time %s for pid %s!\n", time(), getppid());
return Apache2::Const::OK;
}
Here's when I see the unexpected:
* I open two browser tabs so I can run two nearly simultaneous
fetches of the relevant test URL
* I submit first request in one browser tab
* After waiting two seconds I submit the same URL in the other tab
* I'd expect the two separate but identical URLs to run in
different worker 'httpd' processes, and finish nearly two seconds
apart (note the 10-second delay in the script)
* instead, both are run serially on the "parent" 'httpd' process,
and the second one finishes ten seconds after the first ... meaning
both requests were executed serially
* .... what's going on? I apparently don't understand the prefork
MPM thingy.
Here are the last two lines from each of the two URL fetches (that
were started only 2 seconds apart) ... they should same PID, the
parent 'httpd' process, handled both requests:
* Done at time 1201787367 for pid 2828!
* Done at time 1201787377 for pid 2828!
Please comment. Thanks for your time!