Re: Re: [PHP3] How exactly does PHP work ?
| From: | php3 at developersdesk dot com | Date: | Wed, 21 Jun 2000 05:04:14 +0000 |
| Subject: | Re: Re: [PHP3] How exactly does PHP work ? | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-2434@lists.php.net to get a copy of this message | ||
Addressed to: richard@zend.com (Richard Lynch)
php-general@lists.php.net
** Reply to note from richard@zend.com (Richard Lynch) Tue, 20 Jun 2000 19:09:02 -0500
>
> In article <3949EA44.34C34C37@t-edge.com>, mandar@t-edge.com (Mandar
> Deshmukh) wrote:
>
> > I wanted to know, on each new user accessing a php page, what is
> > created on the server? :
> > 1) a object,
> > 2) a thread,
> > 3) a process
> > Learning something about this will give me a clearer picture of php
>
> Using PHP as a Module, I think maybe just a thread, if that much, is
> created. I guess it has to create some sort of discrete thing, since
> one PHP incarnation on a server is independent of another...
>
I don't know about other servers, but with Apache, if you have spare
processes waiting for connections (the normal situation) _nothing_ is
created. Apache spawns some number (StartServers) of servers, and
adjusts thier number (MinSpareServers, MaxSpareServers) to have
pre-spawned processes ready to handle requests. In a module based PHP
install, each of these processes includes PHP code, and is ready to
execute your PHP program. The root Apache process is listening on port
80 and maybe 443 (Listen, VirtualHost) all the time. When a request
comes in it is dispatced to one of the waiting servers. If there
are a large number of processes actively doing work Apache creates more
processes (up to MaxSpareServers) to keep some idle server processes in
memory, ready to handle a request.
This is why you see one Apache process owned by root, and many owned by
nobody. (User, Group)
For more info, read up on the Apache configuration directives listed
above ()...
PS. In an earlier message I mentioned that the root apache process was
needed for re-reading the config files, now that I've thought about it
more, a root process is also needed to be able to listen to ports less
than 1024, on a UNIX based machine. So the main reason for the root
owned process is to listen on the privleged (<1024) port and dispatch
the request to a waiting slave.
Rick Widmer
Internet Marketing Specialists
www.developersdesk.com