Re: How to handle missing pgsql.connect_timeout

From: Keary Suska <hierophant(at)pcisys(dot)net>
To: Postgres-PHP <pgsql-php(at)postgresql(dot)org>
Subject: Re: How to handle missing pgsql.connect_timeout
Date: 2005-02-03 18:41:00
Message-ID: BE27BE4C.19E41%hierophant@pcisys.net
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

on 2/2/05 1:49 AM, vygen(at)planwerk6(dot)de purportedly said:

> It's not broken anymore! And it speeds up your website.

This is true, insofar as you avoid the connection overhead, but in my
experience if your DB is local (i.e. on the same machine as your web site),
the difference amounts to fractions of a second. There are also many
pitfalls to using persistent connections, including greater overhead since
you are far more likely to have idle connections, unless every single HTTP
call includes a database call--and I mean *every* call: images, css,
scripts, etc.

You may also want to set pgsql.auto_reset_persistent to handle broken
persistent links.

>> We were constantly getting connections that wouldn't close, and
>> sometimes not time out. Ever since we gave up on them, we've had no
>> problems.
>
> Thats not exactly my problem. I just want to have say
>
> 20 MaxClients to wait for http Connections
> but only 5 possible DB Connections

In this case, you probably don't want persistent connections at all. To use
persistent connections properly under moderate loads your max clients and
max db connections should be the same, or you will definitely have idle
(i.e. unused) db connections.

> I http server no. 6 tries to connect i want pg_pconnect (or pg_connect; that
> doesn't matter) to wait maximal 1 second and then return an error.

AFAIK, if your max_connections setting in the PG server is 5, the 6th
connection should return with an immediate error. Perhaps this has changed
since I experienced it last--I will leave confirmation up to those who know
PG better.

Best regards,

Keary Suska
Esoteritech, Inc.
"Demystifying technology for your home or business"

In response to

Browse pgsql-php by date

  From Date Subject
Next Message Marco Colombo 2005-02-08 11:25:34 Re: How to handle missing pgsql.connect_timeout
Previous Message Bruce Momjian 2005-02-02 18:15:38 Re: to_char replacement