Re: Hwo to set timeout for PHP persistent connections - Mailing list pgsql-general

From scott.marlowe
Subject Re: Hwo to set timeout for PHP persistent connections
Date
Msg-id Pine.LNX.4.33.0303031117250.12833-100000@css120.ihs.com
Whole thread Raw
In response to Hwo to set timeout for PHP persistent connections  (Gabriele Bartolini <g.bartol@comune.prato.it>)
List pgsql-general
On 3 Mar 2003, Gabriele Bartolini wrote:

> Ciao guys,
>
>    I need to set a reasonable low value of timeout for inactive
> connections, as they seem to stay up when a PHP script calls a
> pg_pconnect on the database server.
>
>    As its main purpose is to serve a Web application, I'd love
> connections to get close after 10-15 seconds of inactivity.
>
>    Is there a run-time configuration I can set in Postgres?

Bad news, the is no timeout.  You should expect there to be as many
persistant connections as there are apachc children times the number of
connections in each child that can happen.

Therefore, it's usually a good idea to configure apache to have fewer max
children than postgresql.  i.e. configure postgresql to handle 128
backends, and apache to run 64 children.  Then you could have two connects
per scripts and you wouldn't quite run out.

The better option is to stop using persistant connects unless you have
proof that connection time is a major impact on the performance of your
machine.

My main box, a Dual PIII 750 can pg_connect about 1,000 times a second.

It can pg_pconnect about 1,000,000 times a second.  Either way, all the
scripts I run take way more than a millisecond to run, and all the queries
I run take hundreds of milliseconds to run as well, so the 1,000th of a
second of a pg_connect may be 1,000 times slower than a pg_pconnect, but
they're both drops in the bucket so to speak, compared to the script
itself.



pgsql-general by date:

Previous
From: "scott.marlowe"
Date:
Subject: Re: Warning: Supplied argument is not a valid PostgreSQL
Next
From: Stephan Szabo
Date:
Subject: Re: almost there on a design