PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > alt.apache.configuration > Prefork-MPM not handing out simultaneous requests to separateprocesses
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
alt.apache.configuration Apache web server configuration issues.

Prefork-MPM not handing out simultaneous requests to separateprocesses

Réponse
 
LinkBack Outils de la discussion
Vieux 31/01/2008, 20h09   #1
urcabraz@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Prefork-MPM not handing out simultaneous requests to separateprocesses

I 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:

<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>

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!
  Réponse avec citation
Vieux 31/01/2008, 20h31   #2
Jim Hayter
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Prefork-MPM not handing out simultaneous requests to separateprocesses

urcabraz@gmail.com wrote:
> I 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.)
>

[snip]
> 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!


Instead of two tabs in one browser, what happens if you do one request
from FireFox and one from IE? The serialization may be an affect of the
browser, not of your apache config. Or it might be affected by the
KeepAlive timeout you have set in the apache config.

HTH,
Jim
  Réponse avec citation
Vieux 31/01/2008, 21h58   #3
urcabraz@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Prefork-MPM not handing out simultaneous requests to separateprocesses


> Instead of two tabs in one browser, what happens if you do one request
> from FireFox and one from IE? The serialization may be an affect of the
> browser, not of your apache config. Or it might be affected by the
> KeepAlive timeout you have set in the apache config.
>
> HTH,
> Jim


Jim,

Thank you very much for your response. I did the multi-browser thing
and sure enough, it worked. The two requests from the separate
browsers that were started about two seconds apart did return the page
at the same time, each after the 10-second delay. So 'httpd' is
passing off the requests to separate children.

I also saw I was mistakenly using 'getppid()' to print process ID OF-
THE-PARENT rather than the process itself. Using '$$' showed the
proper process ID (the child 'httpd' process). I also kept a file
open in the script in read-only mode and used 'lsof' to find which
processes had it opened ... again pointed to the child processes.
Latest results:

[root@fullhouse data]# lsof | grep THE_MARKER
httpd 7338 telosdev 1w REG 253,0 0
2357940 /home/telosdev/THE_MARKER.txt <-- from one browser
httpd 7339 telosdev 1w REG 253,0 0
2357940 /home/telosdev/THE_MARKER.txt <-- from other browser
[root@fullhouse data]# pstree -pn | grep 'httpd'
|-httpd(7336)-+-httpd(7338) <--- this child handles one
request
| |-httpd(7339) <--- this child handles
other request
| |-httpd(7340)
| |-httpd(7341)
| |-httpd(7342)
| |-httpd(7343)
| |-httpd(7344)
| `-httpd(7345)

The last line as returned by each browser page:

* Done at time 1201816544 for pid 7339!
* Done at time 1201816546 for pid 7338!

All is well.

Thanks again! I'm not a web developer, though I've done lots of
server programming. Much to learn yet.

Urca Braz
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h45.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10933 seconds with 11 queries