When reviewing database services in the marketplace, choosing a higher plan is preferred in order to allow a larger concurrent connection size. However, it is not enough to increase the concurrent connection size on the database side only. As far as Ruby on Rails is concerned, the connection pool size should also be adjusted to match the connection size on the database side as well. The default connection pool size is 5 in Ruby on Rails. We have to change the default value in order to achieve maximum concurrent connections.
For Rails versions 4 or before, connection information would read from ENV["DATABASE_URL"]. Ruby buildpack ignores the contents of any database.yml that you provide and overwrites it during staging. So you have to specify the connection pool size in ENV["DATABASE_URL"]. Here is a sample, which connects a mysql database and the connection pool size is set to 15.