aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpawel2105 <brand.magnate@gmail.com>2012-02-21 01:13:47 -0800
committerpawel2105 <brand.magnate@gmail.com>2012-02-21 01:13:47 -0800
commitb2bfb077b58fac448f3a6bc70292d4685ce182c4 (patch)
tree5413704300ea4187437cf1bddc9dd92174a3f66c
parenteb26af6dd3725a76113d69c8fcc923f8d7c77285 (diff)
parent28860d8557663701854e92626b39d8a9207bfca2 (diff)
downloadrails-b2bfb077b58fac448f3a6bc70292d4685ce182c4.tar.gz
rails-b2bfb077b58fac448f3a6bc70292d4685ce182c4.tar.bz2
rails-b2bfb077b58fac448f3a6bc70292d4685ce182c4.zip
Merge pull request #84 from pawel2105/master
Database pooling configuration
-rw-r--r--railties/guides/source/configuring.textile20
1 files changed, 20 insertions, 0 deletions
diff --git a/railties/guides/source/configuring.textile b/railties/guides/source/configuring.textile
index 451235d41d..cd36134e65 100644
--- a/railties/guides/source/configuring.textile
+++ b/railties/guides/source/configuring.textile
@@ -648,3 +648,23 @@ The error occurred while evaluating nil.each
*+set_routes_reloader+* Configures Action Dispatch to reload the routes file using +ActionDispatch::Callbacks.to_prepare+.
*+disable_dependency_loading+* Disables the automatic dependency loading if the +config.cache_classes+ is set to true and +config.dependency_loading+ is set to false.
+
+h3. Database pooling
+
+Active Record database connections are managed by a connection pool base class called +ActiveRecord::Base.connection+. The class ensures that a connection pool synchronizes the amount of thread access to a limited number of database connections. This limit defaults to 5 connections and is configured in +database.yml+.
+
+Below is an example of the pool limit being set to 25 for a development environment.
+
+<ruby>
+ development:
+ adapter: sqlite3
+ database: db/development.sqlite3
+ pool: 25
+ timeout: 5000
+</ruby>
+
+Since all connection pooling is handled inside of ActiveRecord by default, all application servers (Thin, mongrel, Unicorn etc.) should behave the same. Initially, the database connection pool is empty and it will create additional connections as the demand for them increases, until it reaches the connection pool limit.
+
+Any one request will check out a connection the first time it requires access to the database, after which it will check the connection back in, at the end of the request, meaning that the additional connection slot will be available again for the next request in the queue.
+
+Note: If you have enabled +Rails.threadsafe!+ mode then there could be a chance that several threads may be accessing multiple connections simultaneously. So depending on your current request load, you could very well have multiple threads contending for a limited amount of connections.