Rails Database connections

As you add more concurrency to your application it will need more connections to your database. A good formula for determining the number of connections each application will require is to multiply the RAILS_MAX_THREADS by the WEB_CONCURRENCY. This will determine the number of connections each dyno will consume.web

Rails maintains its own database connection pool, with a new pool created for each worker process. Threads within a worker will operate on the same pool. Make sure there are enough connections inside of your Rails database connection pool so that RAILS_MAX_THREADS number of connections can be used. If you see this error:app

ActiveRecord::ConnectionTimeoutError - could not obtain a database connection within 5 seconds

This is an indication that your Rails connection pool is too low. For an in depth look at these topics please read the devcenter article Concurrency and Database Connections.ide

https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#database-connectionsui

https://devcenter.heroku.com/articles/concurrency-and-database-connectionsthis

相關文章
相關標籤/搜索