[plt-scheme] concurrent database connections

From: Dave Gurnell (d.j.gurnell at gmail.com)
Date: Thu Mar 26 11:35:23 EDT 2009

> SPGSQL says:
>
> "Connections are internally synchronized: it is safe to perform
> concurrent queries on the same connection object from different
> threads (by direct query methods or prepared query procedures)."
>
> So given this just use one connection between all your web server  
> threads.
>
> N.

A single connection will presumably make the site slow under load.

I think the default non-superuser concurrent connection limit in  
PostgreSQL is 100. We use the dumb policy of one connection per  
request (put the connection in a thread-cell and connect/disconnect  
using dynamic-wind) and we've never hit it. We've run "stress tests"  
with 50 machines performing >1 request/second. It's not massive by  
Google's standards but it's more than enough for us.

Cheers,

-- Dave



Posted on the users mailing list.