Re: Hwo to set timeout for PHP persistent connections

From: "scott(dot)marlowe" <scott(dot)marlowe(at)ihs(dot)com>
To: Gabriele Bartolini <g(dot)bartol(at)comune(dot)prato(dot)it>
Cc: PostgreSQL-General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Hwo to set timeout for PHP persistent connections
Date: 2003-03-03 18:22:31
Message-ID: Pine.LNX.4.33.0303031117250.12833-100000@css120.ihs.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Stephan Szabo 2003-03-03 18:25:12 Re: almost there on a design
Previous Message scott.marlowe 2003-03-03 18:11:11 Re: Warning: Supplied argument is not a valid PostgreSQL