Ruby eventmachine async client

Elias Levy fearsome.lucidity at
Fri Mar 16 13:34:55 EDT 2012

On Fri, Mar 16, 2012 at 9:00 AM, <riak-users-request at> wrote:

> Given Mathias Meyer's talk at Scotland Ruby Conference about eventmachine
> programming (while wearing a Riak t-shirt!), I was hoping to see a little
> bit more in terms of eventmachine clients and Riak.
> Has anyone used EventMachine and/or em-synchrony with Riak and could give
> me some advice? I'm using ruby-riak-client at this point and going the
> route of trying to wrap my workflow in fibers so riak client plays nice
> with it.
> Am I better off just using a HTTP client like EM::HttpRequest or
> EM::Synchrony::Multi, or is there some good way to use ruby-riak-client or
> ripple with eventmachine that requires less manual intervention?
> Sorry if this has been covered somewhere else but I haven't had much luck
> finding anyone else using EM with Riak.

If you look at the list archive's you'll see that a while ago I posted some
code to monkey patch the Ruby client to use EM Synchrony's TCPSocket so as
to support EM.

You'll find it at

Do note that there is a bug in the emulation that TCPSocket provides that I
submitted to Ilya at
 The issue is that synchrony's TCPSocket behaves like recv, not read, which
can cause problem (short reads if the incoming buffer is not full).  My
initial patch was not a complete fix and I've not had time to revisit the
issue.  Maybe you can take it from there.

In any case, if you don't mind a few dropped connections because of short
reads, the use of synchrony's TCPSocket works relatively well.  We are
using it in production.

Elias Levy
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the riak-users mailing list