Skip site navigation (1) Skip section navigation (2)

Re: PHP and persistent connections

From: Andrew McMillan <Andrew(at)catalyst(dot)net(dot)nz>
To: GH <grasshacker(at)over-yonder(dot)net>, PostgreSQL Novice <pgsql-novice(at)postgresql(dot)org>
Subject: Re: PHP and persistent connections
Date: 2000-11-23 09:01:08
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice
GH wrote:
> I remember seeing something about issues with PHP
> using Postgrs persistent connections. I have been unable to find anything
> in the archives.
> I have been having a problem where backend processes become dedicated to
> a persistent connection and do not die. I do not know if this is caused
> by something in PHP or not.
> I am using pg_pconnect for the connections.
> Is there a solution to this?
> (By the way, kill-ing the backends is NOT a solution. ;-))
> This is running 7.0.2 on FreeBSD 4.0-RELEASE and PHP 4.0.3pl1.
> Any suggestions?
> Eventually, the maximum number of backends is started and the message
> "Sorry, too many clients..." is displayed.
> I thank you all for your assistance.

Each Apache process which does the pconnect will spawn a PostgreSQL
process to handle the connection.  That connection will remain active
for the life of the Apache process, which can naturally be quite long. 
This is what persistent connections are.  If you only want it active for
the life of the PHP script then you don't want persistent connections at

If you have your numbers for Apache processes set quite high you can
very easily run into maximum back-ends limits and also into maximum open
files limits.  These two are adjustable however, with PostgreSQL
controlling the maximum clients through a command-line parameter, and
your operating system controlling the maximum open files through however
FreeBSD does that.

And of course, Apache can control the maximum numbers of processes
started as well.

            Andrew McMillan, e-mail: Andrew(at)cat-it(dot)co(dot)nz
Catalyst IT Ltd, PO Box 10-225, Level 22, 105 The Terrace, Wellington
Me: +64 (21) 635 694, Fax: +64 (4) 499 5596, Office: +64 (4) 499 2267

In response to

pgsql-novice by date

Next:From: Eduardo KotujanskyDate: 2000-11-23 12:28:58
Subject: startup script for FreeBSD
Previous:From: GHDate: 2000-11-23 03:10:55
Subject: PHP and persistent connections

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group