From: Tom Lane <tgl@sss.pgh.pa.us>
To: Juan Miguel <juanmime@ono.com>
Cc: pgsql-admin@postgresql.org
Subject: Re: Postgresql, number of connections and life time
Date: Sat, 28 Jan 2006 11:00:41 -0500
Message-ID: <11868.1138464041@sss.pgh.pa.us> (raw)
In-Reply-To: <43DB2942.3040009@ono.com>
References: <43DB2942.3040009@ono.com>
Juan Miguel <juanmime@ono.com> writes:
> I have a Linux box with postgres 7.4 branche, where web php applications
> queries the DB. When Apache launches a php file that connects to the DB,
> if I do "ps aux | grep postgrest", I can see a process "postgres user
> ...." running, that represents the session openned to the DB. But when
> the php program finishes, and closes the connection, this process does
> not end. Therefore the number of processes are growing while people
> visit the web. ¿ Why ?
Evidently the connection isn't really getting closed. I don't know
enough about PHP to help you with why not, though.
> I gain access this DB remotely by an encrypted connection with stunnel.
> Well, when I launch a connection to a DB, and passes a long time without
> traffic, I realise the connection is closed. The program that queries
> the DB does not realise the connection is broken and when it tries to
> query, it fails. I think that the origin of the problem is not stunnel,
> because the same problem presents to me when trying with a testing DB
> without stunnel. ¿ Why ? Has postgres a timer that breaks the
> connections when there is no traffic ? Has Linux this timmer ?
No, and no, but a lot of router and firewall hardware has idle-timeouts
for connections. Look at the settings for whatever boxes are between
your two machines --- if you're lucky, you can increase the idle
timeout.
More recent versions of PG (I think 8.1 and up) allow you to fool with
the TCP keepalive settings --- reducing those can be used to generate
dummy traffic that will keep the firewall from thinking the connection
is idle.
regards, tom lane
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-admin@postgresql.org
Cc: tgl@sss.pgh.pa.us, juanmime@ono.com
Subject: Re: Postgresql, number of connections and life time
In-Reply-To: <11868.1138464041@sss.pgh.pa.us>
References: <43DB2942.3040009@ono.com> <11868.1138464041@sss.pgh.pa.us>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox