Re: idle connections - Mailing list pgsql-admin

From Steve Crawford
Subject Re: idle connections
Date
Msg-id 4ACB702F.2040505@pinpointresearch.com
Whole thread Raw
In response to Re: idle connections  (Aras Angelo <araskoktas@gmail.com>)
Responses Re: idle connections
List pgsql-admin
Aras Angelo wrote:
> ...
> When i kill the earliest idle process the others stop too. So i dont
> know whats wrong really. All our apps use the same footer, with
> pg_close() at the end....
> ...
> I have done most of the things you guys suggested, so it seems to me
> that something between php-apache-postgresql is not doing good, and it
> only effects us at peak times, so just wondering if killing processes
> every 2-3 minutes, would do harm on our setup....

Are you killing web processes or postgresql processes? If web, you will
probably end up impacting at least some of you users directly. If
PostgreSQL, then you will undoubtedly end up yanking the rug out from
under a process that  expected a working database connection. So yes,
you might cause harm. Worse still, you may not solve the problem.

When I hear symptoms like this, especially when they tend to happen
under load, I start looking for a process that is slowing/blocking the
other processes.

Consider a fairly typical PHP script. It might start out opening a
database connection and then do various queries interspersed with
processing. If one process hogs sufficient resources or is holding some
resource or lock that slows or blocks the other PHP processes then you
could easily see numerous idle PG processes. Kill the "offending"
process and the others will often rapidly complete thus releasing their
connections.

If you have enough traffic to justify three webservers then you probably
have enough traffic to deplete your available pg connections in seconds,
not minutes so keep digging.

Cheers,
Steve


pgsql-admin by date:

Previous
From: Olivier Nicole
Date:
Subject: postgres 8.4 authentication with LDAP
Next
From: Aras Angelo
Date:
Subject: Re: idle connections