EcHo2K
11-05-2001, 17.33.27
vi propongo questo estratto dalle faq di php...
-----
This has to do with the way web servers work. There are three ways
in which your web server can utilize PHP to generate web pages.
The first method is to use PHP as a CGI "wrapper". When run this
way, an instance of the PHP interpreter is created and destroyed for
every page request (for a PHP page) to your web server. Because it
is destroyed after every request, any resources that it acquires (such
as a link to an SQL database server) are closed when it is destroyed.
In this case, you do not gain anything from trying to use persistent
connections -- they simply don't persist.
The second, and most popular, method is to run PHP as a module
in a multiprocess web server, which currently only includes
Apache. A multiprocess server typically has one process (the parent)
which coordinates a set of processes (its children) who actually do
the work of serving up web pages. When each request comes in from a a
client, it is handed off to one of the children that is not already
serving another client. This means that when the same client makes
a second request to the server, it may be serviced by a different
child process than the first time. What a persistent connection does
for you in this case it make it so each child process only needs
to connect to your SQL server the first time that it serves a page
that makes us of such a connection. When another page then requires
a connection to the SQL server, it can reuse the connection that
child established earlier.
The last method is to use PHP as a plug-in for a multithreaded web server. Currently this is only theoretical -- PHP does not
yet work as a plug-in for any multithreaded web servers. Work is
progressing on support for ISAPI, WSAPI, and NSAPI (on Windows),
which will all allow PHP to be used as a plug-in on multithreaded
servers like Netscape FastTrack, Microsoft's Internet Information
Server (IIS), and O'Reilly's WebSite Pro. When this happens, the
behavior will be essentially the same as for the multiprocess model
described before.
-----
ditemi se le mie conclusioni sono giuste...nel caso di PHP+Apache il pconnect apre una connessione permanente per OGNI singolo processo che Apache lancia vero??
quindi e' facile se un server e' sotto un forte carico che Apache lanci molti processi, la machina si potrebbe ritrovare con molte connessioni permanenti aperte delle quali solo una piccolissima parte utilizzate...
ho testato con uno script che mi sono fatto, e le conclusioni mi sembrano giuste...voglio provare con IIS per vedere se si comporta in maniera diversa...
comunque per ora il consiglio e' evitate le pconnect, almeno con apache...come sono realizzate ora in PHP non hanno molto senso perche' servono per ridurre il carico sul server del DB, ma molto facilmente quando si usa Apache lo portano a livelli piu' alti...mah...
-----
This has to do with the way web servers work. There are three ways
in which your web server can utilize PHP to generate web pages.
The first method is to use PHP as a CGI "wrapper". When run this
way, an instance of the PHP interpreter is created and destroyed for
every page request (for a PHP page) to your web server. Because it
is destroyed after every request, any resources that it acquires (such
as a link to an SQL database server) are closed when it is destroyed.
In this case, you do not gain anything from trying to use persistent
connections -- they simply don't persist.
The second, and most popular, method is to run PHP as a module
in a multiprocess web server, which currently only includes
Apache. A multiprocess server typically has one process (the parent)
which coordinates a set of processes (its children) who actually do
the work of serving up web pages. When each request comes in from a a
client, it is handed off to one of the children that is not already
serving another client. This means that when the same client makes
a second request to the server, it may be serviced by a different
child process than the first time. What a persistent connection does
for you in this case it make it so each child process only needs
to connect to your SQL server the first time that it serves a page
that makes us of such a connection. When another page then requires
a connection to the SQL server, it can reuse the connection that
child established earlier.
The last method is to use PHP as a plug-in for a multithreaded web server. Currently this is only theoretical -- PHP does not
yet work as a plug-in for any multithreaded web servers. Work is
progressing on support for ISAPI, WSAPI, and NSAPI (on Windows),
which will all allow PHP to be used as a plug-in on multithreaded
servers like Netscape FastTrack, Microsoft's Internet Information
Server (IIS), and O'Reilly's WebSite Pro. When this happens, the
behavior will be essentially the same as for the multiprocess model
described before.
-----
ditemi se le mie conclusioni sono giuste...nel caso di PHP+Apache il pconnect apre una connessione permanente per OGNI singolo processo che Apache lancia vero??
quindi e' facile se un server e' sotto un forte carico che Apache lanci molti processi, la machina si potrebbe ritrovare con molte connessioni permanenti aperte delle quali solo una piccolissima parte utilizzate...
ho testato con uno script che mi sono fatto, e le conclusioni mi sembrano giuste...voglio provare con IIS per vedere se si comporta in maniera diversa...
comunque per ora il consiglio e' evitate le pconnect, almeno con apache...come sono realizzate ora in PHP non hanno molto senso perche' servono per ridurre il carico sul server del DB, ma molto facilmente quando si usa Apache lo portano a livelli piu' alti...mah...