マルチスレッド環境で Rails の ActiveRecord を使おうとしたところ、以下のエラーに遭遇しました。スレッド毎に、ActiveRecord がDB接続(コネクション)を確保しようとするために、コネクションのプールサイズをオーバーしてしまうのが原因です。 ActiveRecord::ConnectionTimeoutError in SomeController#some_action could not obtain a database connection within 5.000 seconds (waited 5.003 seconds)
![Rails ActiveRecordをマルチスレッドで使う](https://cdn-ak-scissors.b.st-hatena.com/image/square/b27ba1d703068fc4853ea1271440cbb779e7cabb/height=288;version=1;width=512/https%3A%2F%2Feasyramble.com%2Fwp-content%2Fuploads%2F2016%2F03%2Feasyramble_ogp.jpg)