On Sun, Sep 5, 2010 at 8:57 AM, Joshua P.
[email protected] wrote:
I am interested to learn more about connection pooling in rails. Is there
any good articles about this? I want to know specifically how is connection
pooling in rails works. Does rails open one connection to the database for
every user that is connected or does every user share the same database
connection? Does different app server handles connection pooling differently
[i.e passenger, unicorn, mongrel, thin] ? Or does app server doesn’t really
care about this?
Thank you very much in advance for your help and insights.
Here are some facts about connection pooling that should answer your
Connection pooling is handled inside of ActiveRecord, so all
application servers should behave basically the same.
The database connection pool starts out empty and creates
connections over time according to demand. The maximum size of this
pool defaults to 5 and is configured in database.yml.
Requests and users share connections from this pool. A request
checks out a connection the first time it needs to access the database
and then checks the connection back in at the end of the request.
If you use Rails.threadsafe! mode, then multiple threads might be
accessing multiple connections at the same time, so depending on the
request load you might have multiple threads contending for a few