Rails 4: When is the database connection established?

I am deploying a Rails 4 application on Heroku. Since I am browsing the available databases, I do not understand what “communication restriction” means. "Hobby level plans" have a connection limit of 20. The next level has a limit of 60. Now I am curious when the database connection is established, so that I can calculate which plan is best for me. Is there a connection for every request? Because if this is the case, it means that only 20 users can use the application at a time. I want some of them to be cached, but I don’t get it anyway. Thank you in advance!:)

+4
source share
1 answer

When the rails process starts, it will capture a connection to the database and hold that connection until the process stops.

For most Ruby MRI applications, you need 1 connection for each process, you will most likely run a unicorn on a hero with 3 workers on a dyno, each worker will need 1 connection to a database. When you connect to the console heroku run console, which will use the new database connection before exiting the console.

If you use a Ruby thread like jruby, then each thread will need its own database connection.

"Concurrency Ruby ActiveRecord" heroku, :

+1

Source: https://habr.com/ru/post/1543654/


All Articles