Safe to kill idle connections?

Поиск
Список
Период
Сортировка
Искать

Safe to kill idle connections?

От:
Francisco Reyes <lists@natserv.com>
Дата:
Ever since I installed a particular program, PHPWiki, I am seeing idle 
postgres sessions.. even days old. Is it safe to delete them?

For example:
postmaster: wiki simplicato_wiki [local] idle (postgres)

Ultimately I will either switch wiki or take the time and find the piece 
of code that is causing the sessions to remain open, but until then don't 
want to leave those idle sessions around.. for days.

Re: Safe to kill idle connections?

От:
Francisco Reyes <lists@natserv.com>
Дата:
On Mon, 17 Oct 2005, Richard Huxton wrote:

> At a guess, PHPWiki is using persistent connections to PG, so you'll get one 
> connection per Apache backend.

Thanks for the info. That may well be the problem.

> Alternatively, a small change in PHPWiki's code should clear it too (start 
> with a search for pg_pconnect and try pg_connect instead).

Will do.

> It's perfectly safe to leave the idle connections there - they won't take up 
> much in the way of resources.

How about when one needs to reload to read new postgresql.conf files. Will 
iddle connections prevent the server from reloading?

Also, in the future if other programs do the same, is it safe to kill 
these and if so what is the best way? kill command?

Re: Safe to kill idle connections?

От:
Thomas Beutin <tb@laokoon.in-berlin.de>
Дата:
Francisco Reyes wrote:
> Ever since I installed a particular program, PHPWiki, I am seeing idle 
> postgres sessions.. even days old. Is it safe to delete them?
I wouln't do that. These seems to be php persistent connections, and 
they are idle for the moment but reused for new wiki requests.
http://www.php.net/pg_pconnect

> For example:
> postmaster: wiki simplicato_wiki [local] idle (postgres)
> 
> Ultimately I will either switch wiki or take the time and find the piece 
> of code that is causing the sessions to remain open, but until then 
> don't want to leave those idle sessions around.. for days.
If there is no configuration switch, search for pg_pconnect in the code 
and replace it with pg_connect, but if You're running a site with heavy 
traffic i recommend to use the persistent connections for performance 
reasons.

Cheers,
-tb
-- 
Windows: "Where do you want to go today?"
Linux: "Where do you want to go tomorrow?"
FreeBSD: "Are you guys coming, or what?"

Re: Safe to kill idle connections?

От:
Richard Huxton <dev@archonet.com>
Дата:
Francisco Reyes wrote:
> Ever since I installed a particular program, PHPWiki, I am seeing idle 
> postgres sessions.. even days old. Is it safe to delete them?
> 
> For example:
> postmaster: wiki simplicato_wiki [local] idle (postgres)
> 
> Ultimately I will either switch wiki or take the time and find the piece 
> of code that is causing the sessions to remain open, but until then 
> don't want to leave those idle sessions around.. for days.

At a guess, PHPWiki is using persistent connections to PG, so you'll get 
one connection per Apache backend. If you reduce the number of idle 
Apache backends you should reduce the number of idle PG connections too. 
Alternatively, a small change in PHPWiki's code should clear it too 
(start with a search for pg_pconnect and try pg_connect instead).

It's perfectly safe to leave the idle connections there - they won't 
take up much in the way of resources.

HTH
--
   Richard Huxton
   Archonet Ltd

Re: Safe to kill idle connections?

От:
Richard Huxton <dev@archonet.com>
Дата:
Francisco Reyes wrote:
> 
> How about when one needs to reload to read new postgresql.conf files. 
> Will iddle connections prevent the server from reloading?

http://www.postgresql.org/docs/8.0/static/app-pg-ctl.html

> Also, in the future if other programs do the same, is it safe to kill 
> these and if so what is the best way? kill command?

The pg_ctl program handles all your start/stop/reload requirements, 
although it just packages up various "kill" commands internally AFAIK. 
Probably a good idea to use it, since it gives you cross-platform 
compatibility for these things.
-- 
   Richard Huxton
   Archonet Ltd
FAQ