synchronous controllers taking 6 seconds in Eventmachine config

Eric Wong normalperson at yhbt.net
Wed Sep 15 14:50:07 EDT 2010


Christoph Sturm <me at christophsturm.com> wrote:
> hello rainbows friends!
> 
> we use rainbows in eventmachine mode, and it seems there's a bug in
> handling of synchronous responses.
> 
> this controller takes 6 seconds:
> 
> def call(env)
>       Rack::Response.new.finish
> end
> 
> this only occurs when i dont set a content length, for example this
> controller returns immedately:
> 
> def call
>    [200, {'Content-Length' => 2}, ['OK']]
> end
> 
> it also doesnt seem to be eventmachine specific, if i remove the use
> :Eventmachine it also happens.

Hi Chris, this is because the client doesn't know when to stop
reading the connection otherwise, and waits until the keepalive
timeout (5 seconds or so by default).

"Content-Length" (or "Transfer-Encoding") is required by the Rack spec,
so you need to include it in your app (or use
Rack::ContentLength and/or Rack::Chunked middlewares).

Starting with Rainbows! 0.97.0, you can set "keepalive_timeout 0" in
your Rainbows! config block to disable keepalive across all concurrency
models, which lets you violate the Rack spec and get immediate
responses.

-- 
Eric Wong


More information about the rainbows-talk mailing list