Re: Rails & pg setup question - Mailing list pgsql-general

From Joshua D. Drake
Subject Re: Rails & pg setup question
Date
Msg-id 4F49207B.4030107@commandprompt.com
Whole thread Raw
In response to Rails & pg setup question  (Scott Ribe <scott_ribe@elevated-dev.com>)
List pgsql-general
On 02/25/2012 08:13 AM, Scott Ribe wrote:
>
> What I'm trying to determine is: should I plan on using pgbouncer?
>
> With Rails&  Passenger, do the app server processes take and hold connections to the db? Or take&  release with
queries/connections?
>
> This is not a scalability question; given the traffic the site will have I only need a small handful of connections.
It'sa latency question, I don't want to be starting up new pg processes excessively. 
>
> (Yes, I thought about asking on the RoR list, since it's really a question about RoR behaviors, but on the other hand
itinvolves pg optimization&  best practice, which is, ahem, different than with MySQL.) 
>

Alright I did a quick google and passenger appears to be essentially
mod_rails, which means you are going to generate a connection for every
httpd process you have (unless something has changed that I don't know
about).

So on the one hand it is good because your connections will be
persistent, on another hand it is bad because you will open connections
even if you aren't using the database. That said, it is a rails app so
it is likely you are using the database no matter what.

Where pgbouncer might come in handy here, is that it can open more
connections than you have httpd processes, and thus you will reduce the
fork cost of the new process just because someone hits the website.

JD

--
Command Prompt, Inc. - http://www.commandprompt.com/
PostgreSQL Support, Training, Professional Services and Development
The PostgreSQL Conference - http://www.postgresqlconference.org/
@cmdpromptinc - @postgresconf - 509-416-6579

pgsql-general by date:

Previous
From: Scott Ribe
Date:
Subject: Rails & pg setup question
Next
From: Daniel Podlejski
Date:
Subject: Re: Rails & pg setup question