How to manage growing memory with Rainbows!

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


Claudio Poli <claudio at audiobox.fm> 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: http://pastie.org/private/zepmdeduvlrvtdkc32unnq
> 
> 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: https://groups.google.com/forum/?fromgroups=#!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] ||= Redis.new(url: url)
  end

This won't work well for ThreadSpawn.


More information about the rainbows-talk mailing list