Re: idle connections

From: Steve Crawford <scrawford(at)pinpointresearch(dot)com>
To: Aras Angelo <araskoktas(at)gmail(dot)com>
Cc: pgsql-admin(at)postgresql(dot)org
Subject: Re: idle connections
Date: 2009-10-05 23:12:48
Message-ID: 4ACA7D70.5050405@pinpointresearch.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Aras Angelo wrote:
> Hi,
>
> Im seeing lots of idle connections (not idle in transaction) to my
> database server. My front end is written with PHP and i couldnt find
> anything that can cause this. If i do a kill proc-id every few minutes
> on my server via cron, would this effect anything badly?
>
> Thanks
Before you go killing things willy-nilly, try diagnosing the problem -
papering over problems is almost never a good "solution". In fact,
depending on your designs and workloads, this might be a good thing (if
intentional and understood).

Use (as root) "lsof -i :5432" or your favorite equivalent for your OS.

First run it on the database server to verify that the connections are
from your webserver. If so, run it on your webserver and verify that the
processes are what you think they are.

If PHP (which will probably show up as an Apache or whatever webserver
you are running process), you may have one or more scripts opening
persistent connections. Or a bug. I've seen PHP scripts hang leaving an
open connection to the database. Or it could be a persistent connection
opened by a Perl/Python/Ruby/whatever-else-you-have program so you may
have to check those as well. Perhaps look at the connection start time
in PG and try to correlate it with a request in your webserver log.

I assume you would have told us if you are running pgbouncer or similar
pooling solution as that would be an obvious cause.

Cheers,
Steve

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message Lee, Mija 2009-10-05 23:47:42 constraints set to deferrable by default
Previous Message u235sentinel 2009-10-05 22:58:15 compiling postgres with static libraries?