X-Original-To: pgsql-php-postgresql.org@localhost.postgresql.org Received: from localhost (neptune.hub.org [200.46.204.2]) by svr1.postgresql.org (Postfix) with ESMTP id CE049D1DC6A for ; Mon, 15 Dec 2003 21:35:57 +0000 (GMT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (neptune.hub.org [200.46.204.2]) (amavisd-new, port 10024) with ESMTP id 21203-05 for ; Mon, 15 Dec 2003 17:35:37 -0400 (AST) Received: from server.yourfacility.com (server.yourfacility.com [207.103.74.10]) by svr1.postgresql.org (Postfix) with SMTP id 5412FD1DC1B for ; Mon, 15 Dec 2003 17:35:29 -0400 (AST) Received: (qmail 71830 invoked by uid 0); 15 Dec 2003 21:35:39 -0000 Received: from unknown (HELO ROD) (141.149.246.2) by server.yourfacility.com with SMTP; 15 Dec 2003 21:35:39 -0000 From: "Rod K" To: "Sylvain Ross" , Subject: Re: What is wrong with pg_pconnect() ? Date: Mon, 15 Dec 2003 16:35:33 -0500 Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook IMO, Build 9.0.2416 (9.0.2910.0) Importance: Normal In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 X-Virus-Scanned: by amavisd-new at postgresql.org X-Archive-Number: 200312/37 X-Sequence-Number: 2483 Your apache process shouldn't be dying after the keep alive timeout and probably isn't. Which is why the pg process isn't dying, it is still connected to the apache child that made the connection. What you want to look at in httpd.conf is MaxRequestsPerChild. That is the number of non-keep alive requests the child will handle before dying. If "0" then it won't die due to number of requests. So, in your scenario, that child only handled one request (subsequent requests via keep-alive don't count). That connection will remain open until the apache child dies or pg times out the connection. The various *_pconnect functions in PHP are powerful but not suited to all purposes. If your web server handles a lot of static pages, images and even dynamic pages that don't connect to the DB then persistent connections aren't necessarily a good solution. The other place they REALLY suck is on a shared server. Imagine 50 different clients using persistent connections to the DB. If persistent connections are used, it is entirely possible that each apache child has 50 different connections to the DB due to the fact that each client is probably using different parameters to connect (different PG users). Now multiply 50 connections by the number of apache children! Your server will come to it's knees rather quickly. I've told a number of hosting providers to turn off the persistent connection functions. > -----Original Message----- > From: pgsql-php-owner@postgresql.org > [mailto:pgsql-php-owner@postgresql.org]On Behalf Of Sylvain Ross > Sent: Monday, December 15, 2003 3:10 PM > To: pgsql-php@postgresql.org > Subject: [PHP] What is wrong with pg_pconnect() ? > > > Hi, > > I read a few sites (including php.net, article about db persistent > connections) speaking about the adventage of pg_pconnect() php function... > > I got a "big" problem with pconnections made with the pg_pconnect > function. > The problem is the following : > > > I'm using a stable debian with: > apache 1.3.26 > php 4.1.2 > postgres 7.2 > > (I know some guys thinks those are old versions... no, it's just debian > stable versions ;)) > > > So , here is the pb : > > - A client connects for the first time to my httpd and load a script which > contain a pg_pconnect() call, what create a pgsql process... so > far so good > ... > > - As my httpd is in keepalive mode (wiuth a keepalive_timeout of 15 secs), > if the user loads another page with an other pg_pconnect() call (with the > same parameters as the first pconnect()), it uses the same pgsql process > created before. Cool ! pconnect is great ! > > - BUT, when the keepalive times out, the dedicated apache process > dies (what > is normal), BUT the pgsql thread is still alive ! with "idle" state ! > > Of course, since the related apache process has died, this idling pgsql > process will stay in memory for ever ! won't be reused ever ! > > I don't know how to deal with this ! If the pgsql forked-process where > killed when apache forked-process die, all should be OK ! but it > does not :( > > > Tell me if there are any solutions... > > Thanks in advance. > > Sylvain > > > ---------------------------(end of broadcast)--------------------------- > TIP 6: Have you searched our list archives? > > http://archives.postgresql.org > >