[Backgroundrb-devel] 1) Error 2) sending request to a specific worker

hemant gethemant at gmail.com
Mon Dec 17 00:52:40 EST 2007

Hi Chris,

> I've been developing a chat middle-ware solution for a client
> (bunnybot.com). This is a the approach I've taken. We make heavy use
> of XMPP/Jabber, run OpenFire on the back-end, and need to be able to
> maintain user presence information. I've created a light-weight client
> worker that manages pools of user proxy objects inspired by xmpp4r-
> simple. Using this approach, a single worker can scale to maintain a
> pretty good size collection of connections (I've tested with 100's,
> don't see why it couldn't be more pretty much limited to OS
> resources). The worker and the app communicate in the standard way,
> with simple keys that identify the instance of the proxy object, and
> serialize key data (e.g. rosters, presence updates, messages, etc).
> I've got a few more things to do on the implementation, being paused
> while finishing other deployments, but am happy to discuss.
> I had the first version of this running under the older bdrb code-base
> using a self-managed set of threads. I'm moving it to the HEAD and
> looking at the new tcp connections in the event loop Hemant mentions.
> If others are doing similar things and can share knowledge, gotchas,
> or even code, that would be cool. A few of us have exchanged some
> messages over at RailsForum and RubyOnRails-Talk, so check those
> places for other leads.

My idea of managing everything from single worker is pretty simple.

Keep all sever connections in hash, something like in create method of worker:

def create
  @open_connections = {}
  @open_connection_mutex = Mutex.new

def login(details)
  thread_pool.defer(details) do |details|
     login_resp = login_using_details
     @open_connection_mutex.sychronize do
        @open_connections[user_id] = connection_info

def send_message(message)
  thread_pool.defer(message) do |message|
    user_info = message.user_id
    connection = nil
    @open_connection_mutex.sychronize do
       @connection = @open_connections[user_info]

Where threa_pool is a ThreadPool that is available right inside
backgroundrb workers.

Let them talk of their oriental summer climes of everlasting
conservatories; give me the privilege of making my own summer with my
own coals.


More information about the Backgroundrb-devel mailing list