Re: Rails & pg setup question

From: "Joshua D(dot) Drake" <jd(at)commandprompt(dot)com>
To: Scott Ribe <scott_ribe(at)elevated-dev(dot)com>
Cc: Postgresql General <pgsql-general(at)postgresql(dot)org>
Subject: Re: Rails & pg setup question
Date: 2012-02-25 17:55:07
Message-ID: 4F49207B.4030107@commandprompt.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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's a 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 it involves 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Daniel Podlejski 2012-02-25 23:41:02 Re: Rails & pg setup question
Previous Message Scott Ribe 2012-02-25 16:13:59 Rails & pg setup question