HTTP streaming and Unicorn timeout

Eric Wong normalperson at yhbt.net
Wed Aug 21 16:41:44 UTC 2013


Nokan Emiro <uzleepito at gmail.com> wrote:
> Hi guys,
> 
> I am working on a Rails app that needs to stream some data to the user and
> I have just found out that Unicorn's timeout feature doesn't respect streaming.
> Content generation is interrupted by Unicorn after the timeout is over.  I
> had to comment out the timeout line in the Unicorn config and use
> Rack::Timeout instead.  This way the streaming isn't interrupted, but the normal
> requests (I mean those that don't use streaming) are forced to finish in the
> defined period of time.
> 
> I'd like to know your opinion about that.  Why is Unicorn cutting off the app
> even if it streams actively to the user?  Is there any better solutions to my
> problem than using Rack::Timeout and switch off timing out in Unicorn?

unicorn isn't appropriate for long-running responses (taking up an
entire process is expensive), it is designed for fast responses to a
fast client able to read it quickly.

Using Rack::Timeout with Rainbows! instead of unicorn is probably a
better idea.

> Is that a bad idea that the timeout counter should restart counting after
> each byte/packet/chunk traverses trough the connection?

That'd be more expensive for the common case of fast responses
(which is what unicorn is designed for)


More information about the mongrel-unicorn mailing list