

In Rails, database configurations are set in the config/database.yml file. Source: The ActiveRecord::Connection Pool. It will also handle cases in which there are more threads than connections: if all connections have been checked out, and a thread tries to checkout a connection anyway, then ConnectionPool will wait until some other thread has checked in a connection. The basic idea is that each thread checks out a database connection from the pool, uses that connection, and checks the connection back in. Different requests are handled on different threads, so a connection pool is necessary to maintain a limited set of connections to the database and also to skip the additional latency of establishing a TCP connection.Ī connection pool synchronises thread access to a limited number of database connections.

BackgroundĪctiveRecord is the canonical ORM for Rails to access a database. It was expected that the server should continue functioning for endpoints which do not depend on this database, but it was observed that our server slowed down to a crawl, and was unable to function properly even after the failover completed, until we manually restarted the servers. One of the databases that the application connects to had a failover event. A couple of weeks ago, we had a production outage for one of our internal Ruby on Rails application servers.
