Single Threaded Async Responses

Eric Wong normalperson at
Mon Oct 5 18:56:33 EDT 2009

James Tucker <jftucker at> wrote:
> Hi Eric and anyone else listening in,
> I completed an async API for Thin quite some time ago well suited to  
> some of the design goals you have here. If you're interested we could  
> have a chat about supporting the same API designs that allow single  
> threaded reactor based concurrent responses. I believe such an API would 
> fit well in rainbows too.

Hi James,

This sounds interesting.

Does this mean it does synchronous request reading?  That'll mean
it requires nginx in front to work well.

So the response is written asynchronously, meaning it can be bigger than
the outgoing TCP buffers and still not block, right?  I considered
something like this for Unicorn, too, but then I realised that all the
responses I see managed to fit into the TCP buffers without blocking

But for weird OSes with tiny buffers or apps dealing with large
responses it would probably make sense for Rainbows! (especially
if you plan to help me support it into the future :)

Is it merged into Thin already?  Where can/should I take a look?

One bit to be careful for is the body of the Rack response may not be a
simple Array of String objects, so that requires extra effort/cycles to
stringify into something that can be buffered for async writes.  But
then that could be a huge chunk to keep around in memory (since we
mainly need this to support larger responses).  What nginx does is
it will buffer into a temporary file and then sendfile() it over
as the socket becomes readable.

Eric Wong

More information about the rainbows-talk mailing list