提交 607dfb64 编写于 作者: C Claudio B.

Merge pull request #20905 from imtayadeway/tw/fix-db-pooling-docs

[skip ci] Improve grammar/style in DB pooling guide.
...@@ -1084,22 +1084,22 @@ development: ...@@ -1084,22 +1084,22 @@ development:
timeout: 5000 timeout: 5000
``` ```
Since the connection pooling is handled inside of Active Record 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. Since the connection pooling is handled inside of Active Record by default, all application servers (Thin, mongrel, Unicorn etc.) should behave the same. The database connection pool is initially empty. As demand for connections increases it will create them 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. Any one request will check out a connection the first time it requires access to the database. At the end of the request it will check the connection back in. This means 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 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 you and wait for a connection from the pool. If it cannot get a connection, a
error similar to given below will be thrown. timeout error similar to that given below will be thrown.
```ruby ```ruby
ActiveRecord::ConnectionTimeoutError - could not obtain a database connection within 5 seconds. The max pool size is currently 5; consider increasing it: 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 If you get the above error, you might want to increase the size of the
pool by incrementing the `pool` option in `database.yml` connection pool by incrementing the `pool` option in `database.yml`
NOTE. If you are running in a multi-threaded environment, 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. NOTE. If you are running in a multi-threaded environment, 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 number of connections.
Custom configuration Custom configuration
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册