Feature Request: Rails forces excessive Redis Connection Use - needs support for passing pools

Configure ActionCable, Sidekiq, and Caching to all use Redis. Then throw in any direct use via redis-rb or such for good measure. The 3 native rails ones will all generate their own pools of connections. If you had 20 threads, you would likely end up with ~60+ connections while you could never really use all of those because one thread can’t be using a connection for each use at the same time.

Note that even if there is the instinctive “you should not put Cache and Queueing in the same redis instance” it still makes sense to have 2 redis instances in total - one for persistent items like queues and another for transient items like cache. And users should be able to make use of those connections for the same types of purposes the same way they can with ActiveRecord::Base.connection.

Expected behavior

There should be an ability to configure anything in Rails that needs access to Redis using a ConnectionPool instead of config settings only. That way users can create their pools once and pass them in. It would be even better if there was a concept of a default redis pool that you could set and others would fall back to.

Additionally, it would be great if you could access the connection pool instance each service was using similar to ActiveRecord::Base.connection.

My real dream would be putting in a canonical location for this like Rails.application.pools.redis.persistent and Rails.application.pools.redis.transient that can be configured optionally and things that use Redis can draw from there. Obviously other pools like Memcached could be put there too.



Update: I now notice that Kredis, which is in the Rails Github account itself, at least sets a standard of where to keep config info for Redis which is a slight win. Having common connection pools would be the bigger win.