Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can one Rails app use multiple Redis instances?

We have a Ruby on Rails app on Heroku that's using Redis for several independent functions -- e.g. caching various things via redis-store, hosting Resque queues, and temporary data storage. We're scaling up rapidly, and recently switched from RedisToGo to our own EC2-hosted instance. But our memory and connection usage is still growing. Is it possible for the Rails app to establish connections with different Redis instances for different purposes?

like image 463
Bob Gale Avatar asked Sep 19 '25 07:09

Bob Gale


1 Answers

Yes, it is.

This depends somewhat on how you're connecting to (and using) redis. But there's nothing stopping any Rails application from opening as many connections to as many redis servers as you like. If you're going to be connecting from multiple servers to one redis instance, I would encourage you to check out the connection_pool gem -- it'll help synchronize all of your threads and prevent you from overwhelming the server with clients.

like image 141
Veraticus Avatar answered Sep 22 '25 07:09

Veraticus