Re: idle connections

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Aras Angelo <araskoktas(at)gmail(dot)com>
Cc: Scott Marlowe <scott(dot)marlowe(at)gmail(dot)com>, pgsql-admin(at)postgresql(dot)org
Subject: Re: idle connections
Date: 2009-10-06 16:28:31
Message-ID: 4ACB702F.2040505@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Responses

Browse pgsql-admin by date

  From Date Subject
Next Message Aras Angelo 2009-10-06 16:42:58 Re: idle connections
Previous Message Olivier Nicole 2009-10-06 04:19:45 postgres 8.4 authentication with LDAP