We use Rails 2.3.5, MySQL, and WEBrick.
ActiveRecord call ConnectionPool#checkout and create new connection to MySQL when receive a first HTTP request. At this time, register to connection pool its connection in ConnectionPool#checkout_new_connection. # rails/connection_pool.rb at v2.3.5 · rails/rails · GitHub # rails/connection_pool.rb at v2.3.5 · rails/rails · GitHub
but, Rack::Handler::WEBrick#service call body.close in ensure section when return the HTTP response. It call another method. after some call, it call ConnectionPool#clear_reloadable_connections and clear its connection pool. # rails/connection_pool.rb at v2.3.5 · rails/rails · GitHub
As a result, the connection was created by every request and spend time for connection.
How to use connection pool?