Skip to content

Commit

Permalink
Add notes about database connection pool [ci skip]
Browse files Browse the repository at this point in the history
  • Loading branch information
gaurish committed Sep 22, 2013
1 parent 8000835 commit 73b6095
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
11 changes: 11 additions & 0 deletions guides/source/configuring.md
Original file line number Diff line number Diff line change
Expand Up @@ -759,4 +759,15 @@ Since the connection pooling is handled inside of Active Record by default, all

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.

If you try to use more connections than are available, Active Record will block
and wait for a connection from the pool. When it cannot get connection, a timeout
error similar to given below will be thrown.

```ruby
ActiveRecord::ConnectionTimeoutError - could not obtain a database connection within 5 seconds. The max pool size is currently 5; consider increasing it:
```

If you get the above error, you might want to increase the size of connection
pool by incrementing the `pool` option in `database.yml`

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.
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ production:
adapter: postgresql
encoding: unicode
database: <%= app_name %>_production
# For details on connection pooling, see rails configration guide
# http://guides.rubyonrails.org/configuring.html#database-pooling
pool: 5
username: <%= app_name %>
password:

0 comments on commit 73b6095

Please sign in to comment.