celluloid / reel

UNMAINTAINED: See celluloid/celluloid#779 - Celluloid::IO-powered web server
https://celluloid.io
MIT License
596 stars 87 forks source link

Pipelining Hangs Reel Server #69

Closed vindir closed 11 years ago

vindir commented 11 years ago

Hi there, we're currently trying to use Reel as an Adhearsion plugin for some simple statistics reporting, but we've found (thanks @halorgium) that when people make requests from a browser the socket re-use is causing our service to hang up.

We don't necessarily need pipelining to work - a way to stop it from hanging the service or a way to deny user agents before a hang can occur would be enough to move forward. Hoping you may have ideas on a workaround.

A minimal reproduction: https://github.com/vindir/virginia-keepalive

Thanks!

tarcieri commented 11 years ago

Note that we're "sunsetting" Reel::App and moving it into a separate gem. I would not recommend it going forward. Octarine is unmaintained.

There's a bug in the latest Celluloid that affects all subclasses of Reel, possibly including the Rack adapter. That may be what you're running into.

The best solution is to skip the Rack adapter entirely. Pipelining (which doesn't entirely work yet, see #56) absolutely will not work with the Rack adapter.

vindir commented 11 years ago

Thanks for the reply, one of our first steps was actually taking Reel::App out of the equation.

The example repro above has been updated to use a bare handler without Reel::App.

It fails the same without Reel::App the test script. I had noticed #55 will likely solve our problem, but didn't figure I could count on it going in soon. Do you figure waiting on that to be merged or updated is our only solution for now?

tarcieri commented 11 years ago

I think you forgot to push or something. Last commit on https://github.com/vindir/virginia-keepalive was yesterday

I'm pretty wary about merging #56 as is. It's doing some pretty crazy shit: https://github.com/celluloid/reel/pull/56/files#r4929616

vindir commented 11 years ago

It was pushed to master. Deleted the branch and pushed the App-less version to develop.

Reading through the PR it looks like there should be a cleaner way, a few quick searches shows there isn't a ton of info out there on properly supporting pipelining though.

tarcieri commented 11 years ago

I'm confused... where is the Reel server being defined?

vindir commented 11 years ago

Sorry, I should have been more explicit on the setup here.

Reel is being pulled in as an Adhearsion plugin we've named Virginia. https://github.com/polysics/virginia/tree/old_handler

The actual service is being initialized in https://github.com/polysics/virginia/blob/old_handler/lib/virginia/service.rb#L6-L11

The virginia plugin abstracts away the service from the user so someone using Adherasion only sets up a handler like the one at https://github.com/vindir/virginia-keepalive/blob/develop/lib/stats/ahn_stats.rb and configures it via https://github.com/vindir/virginia-keepalive/blob/develop/config/adhearsion.rb#L14-L15

lpradovera commented 11 years ago

Here is a very minimal reproduction not using Adhearsion or Virginia: https://github.com/polysics/reel_repro

tarcieri commented 11 years ago

@polysics thanks, that's quite helpful!

Just a note that pipelining is NOT officially supported yet, but it should be

lpradovera commented 11 years ago

We do not care for pipelining "on principle", in the sense that we do not really need it, we would just like Reel to not stop responding. Any sensible way to handle that would thus be ok. Thanks for your time!