Rack middleware for shared connection pools?

I have a Rails app that makes connections to other DBs. There may be multiple users connecting to multiple DBs.

The app makes a database connection as part of an action. However, I noticed a problem: there’s too many DB connections remaining open, which is causing the DB to not have enough connections remaining for new connections.

So the answer is using a shared connection pool. Importantly, the connection pool needs to be shared amongst different actions / HTTP requests.

Is there any middleware that extends Sequel’s or ActiveRecord’s connection pool to do this? (Or some code that someone can suggest to do this?)

Thanks.

I don’t know of a middleware that does this but you might want to look at the connection_pool gem ( https://github.com/mperham/connection_pool )

Fred