Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
* synchronous controllers taking 6 seconds in Eventmachine config
@ 2010-09-15 13:46 Christoph Sturm
       [not found] ` <2B157204-E5C6-4F5D-98A9-E2A79F9F9765-Nf+wZpSdgweeYOMve9Zru9BPR1lH4CV8@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Christoph Sturm @ 2010-09-15 13:46 UTC (permalink / raw)
  To: rainbows-talk-GrnCvJ7WPxnNLxjTenLetw

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.

-chris
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: synchronous controllers taking 6 seconds in Eventmachine config
       [not found] ` <2B157204-E5C6-4F5D-98A9-E2A79F9F9765-Nf+wZpSdgweeYOMve9Zru9BPR1lH4CV8@public.gmane.org>
@ 2010-09-15 18:50   ` Eric Wong
       [not found]     ` <20100915185007.GA13709-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2010-09-15 18:50 UTC (permalink / raw)
  To: Rainbows! list

Christoph Sturm <me-Nf+wZpSdgweeYOMve9Zru9BPR1lH4CV8@public.gmane.org> 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
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: synchronous controllers taking 6 seconds in Eventmachine config
       [not found]     ` <20100915185007.GA13709-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
@ 2010-09-15 19:30       ` James Tucker
       [not found]         ` <97F7A036-4DA6-4CF3-B842-5870F7DE59E7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: James Tucker @ 2010-09-15 19:30 UTC (permalink / raw)
  To: Rainbows! list

Eric, you don't do actual keepalive do you, or am i thinking of unicorn?

If the request is sync, then you can close connection after body.each returns, else you need to use the deferrable api callback in deferrable bodies wiht the async api.
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: synchronous controllers taking 6 seconds in Eventmachine config
       [not found]         ` <97F7A036-4DA6-4CF3-B842-5870F7DE59E7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
@ 2010-09-15 21:04           ` Eric Wong
       [not found]             ` <20100915210404.GA21719-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
  0 siblings, 1 reply; 5+ messages in thread
From: Eric Wong @ 2010-09-15 21:04 UTC (permalink / raw)
  To: Rainbows! list

James Tucker <jftucker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> Eric, you don't do actual keepalive do you, or am i thinking of
> unicorn?

Rainbows! has had keepalive and pipelining since the earliest releases
for simple GET/HEAD requests.  At least there are integration tests
using curl that do keepalive, so it should work :)  Keepalive for
proxying sockets/pipes (without async.callback) has improved with recent
releases, too.

Rainbows! will support keepalive for all other body-less requests, too,
and _maybe_ optionally supporting keepalive PUT/POST requests with a
body.  For requests with a body, the app must consume the entire body
(which intentionally does not happen for "synchronous" concurrency
models).

Unicorn doesn't do keepalive since nginx doesn't do keepalive to
backends, yet.   That will change if nginx (or another comparable
frontend emerges) supports keepalive to the backends.

> If the request is sync, then you can close connection after body.each
> returns, else you need to use the deferrable api callback in
> deferrable bodies wiht the async api.

The EM deferrable doesn't do keepalive right now, and may not ever
because (I assume) it's used for long-polling and such.

Setting "keepalive_timeout 0" for any app doing long-polling/Comet stuff
is probably a good idea anyways, the client can't reliably know which
requests take a long time.

-- 
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: synchronous controllers taking 6 seconds in Eventmachine config
       [not found]             ` <20100915210404.GA21719-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
@ 2010-09-17  9:00               ` Eric Wong
  0 siblings, 0 replies; 5+ messages in thread
From: Eric Wong @ 2010-09-17  9:00 UTC (permalink / raw)
  To: Rainbows! list

Eric Wong <normalperson-rMlxZR9MS24@public.gmane.org> wrote:
> James Tucker <jftucker-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > If the request is sync, then you can close connection after body.each
> > returns, else you need to use the deferrable api callback in
> > deferrable bodies wiht the async api.
> 
> The EM deferrable doesn't do keepalive right now, and may not ever
> because (I assume) it's used for long-polling and such.

Would supporting keepalive for people using "async.callback" help some
folks?   As of 0.97.0, it's possible to disable keepalive entirely
across all concurrency models, so perhaps allowing the app to specify
the "Connection" header is helpful, too...

-- 
Eric Wong
_______________________________________________
Rainbows! mailing list - rainbows-talk-GrnCvJ7WPxnNLxjTenLetw@public.gmane.org
http://rubyforge.org/mailman/listinfo/rainbows-talk
Do not quote signatures (like this one) or top post when replying


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2010-09-17  9:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-09-15 13:46 synchronous controllers taking 6 seconds in Eventmachine config Christoph Sturm
     [not found] ` <2B157204-E5C6-4F5D-98A9-E2A79F9F9765-Nf+wZpSdgweeYOMve9Zru9BPR1lH4CV8@public.gmane.org>
2010-09-15 18:50   ` Eric Wong
     [not found]     ` <20100915185007.GA13709-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2010-09-15 19:30       ` James Tucker
     [not found]         ` <97F7A036-4DA6-4CF3-B842-5870F7DE59E7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2010-09-15 21:04           ` Eric Wong
     [not found]             ` <20100915210404.GA21719-yBiyF41qdooeIZ0/mPfg9Q@public.gmane.org>
2010-09-17  9:00               ` Eric Wong

Code repositories for project(s) associated with this inbox:

	../../../rainbows.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).