How to manage growing memory with Rainbows!

Eric Wong normalperson at
Thu Feb 14 20:28:28 UTC 2013

Claudio Poli <claudio at> wrote:
> I have few more questions before definitely make the switch if you don't mind.
> ActiveRecord/Redis.
> This is the configuration I'm trying out in staging:
> Is there something special that should I know about AR connection pool and Rainbows! + Threadpool? My pool in database.yml is 30.

As long as your database can handle the number of connections you have,
you're probably fine.  Keep in mind you'll have 30 connections
per-process (not per-thread), so take that into account if you need to
change the process count or start an upgrade with SIGUSR2.

> After a small load test currently I'm sitting around 60/80 connections, which is kinda expected given that also Sidekiq is in action.
> I don't like the global $redis connection. Can you, or anyone else, offer any advice how to improve that, if you use it in your projects?
> The goal was to keep a connection alive in a single process due to the sheer number of commands that can be put in redis as consequence of actions, but now that I'm using threads it probably needs to be changed.
> The cost however for opening a new connection seems high, I was reading this:!topic/redis-db/xcz5MXykXdk

I have no experience using Redis, but I know it's a TCP-based service.

The easiest might be a Thread-local connection with ThreadPool:

  def redis
    Thread.current[:my_app_redis] ||= url)

This won't work well for ThreadSpawn.

More information about the rainbows-talk mailing list