From: Andrew McMillan <andrew@catalyst.net.nz>
To: Jón Ragnarsson <jonr@physicallink.com>
Cc: pgsql-performance@postgresql.org
Subject: Re: 100 simultaneous connections, critical limit?
Date: Thu, 15 Jan 2004 15:57:08 +1300
Message-ID: <1074135427.3198.213.camel@kant.mcmillan.net.nz> (raw)
In-Reply-To: <40053A91.5060001@physicallink.com>
References: <40053A91.5060001@physicallink.com>
On Thu, 2004-01-15 at 01:48, Jón Ragnarsson wrote:
> I am writing a website that will probably have some traffic.
> Right now I wrap every .php page in pg_connect() and pg_close().
> Then I read somewhere that Postgres only supports 100 simultaneous
> connections (default). Is that a limitation? Should I use some other
> method when writing code for high-traffic website?
Whether the overhead of pg_connect() pg_close() has a noticeable effect
on your application depends on what you do in between them. TBH I never
do that second one myself - PHP will close the connection when the page
is finished.
I have developed some applications which are trying to be
as-fast-as-possible and for which I either use pg_pconnect so you have
one DB connection per Apache process, or I use DBBalancer where you have
a pool of connections, and pg_connect is _actually_ connecting to
DBBalancer in a very low-overhead manner and you have a pool of
connections out the back. I am the Debian package maintainer for
DBBalancer.
You may also want to consider differentiating based on whether the
application is writing to the database or not. Pooling and persistent
connections can give weird side-effects if transaction scoping is
bollixed in the application - a second page view re-using an earlier
connection which was serving a different page could find itself in the
middle of an unexpected transaction. Temp tables are one thing that can
bite you here.
There are a few database pooling solutions out there. Using pg_pconnect
is the simplest of these, DBBalancer fixes some of it's issues, and
others go further still.
Another point to consider is that database pooling will give you the
biggest performance increase if your queries are all returning small
datasets. If you return large datasets it can potentially make things
worse (depending on implementation) through double-handling of the data.
As others have said too: 100 is just a configuration setting in
postgresql.conf - not an implemented limit.
Cheers,
Andrew McMillan.
-------------------------------------------------------------------------
Andrew @ Catalyst .Net .NZ Ltd, PO Box 11-053, Manners St, Wellington
WEB: http://catalyst.net.nz/ PHYS: Level 2, 150-154 Willis St
DDI: +64(4)916-7201 MOB: +64(21)635-694 OFFICE: +64(4)499-2267
How many things I can do without! - Socrates
-------------------------------------------------------------------------
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-performance@postgresql.org
Cc: andrew@catalyst.net.nz, jonr@physicallink.com
Subject: Re: 100 simultaneous connections, critical limit?
In-Reply-To: <1074135427.3198.213.camel@kant.mcmillan.net.nz>
References: <40053A91.5060001@physicallink.com> <1074135427.3198.213.camel@kant.mcmillan.net.nz>
* 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