Rainbows! Rack HTTP server user/dev discussion
 help / color / mirror / code / Atom feed
* dealing with client disconnects with TeeInput
@ 2009-11-12 10:04 Eric Wong
  2009-11-14  1:16 ` Eric Wong
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2009-11-12 10:04 UTC (permalink / raw)
  To: mongrel-unicorn-GrnCvJ7WPxnNLxjTenLetw,
	rainbows-talk-GrnCvJ7WPxnNLxjTenLetw

Foreword: this probably doesn't affect nginx+Unicorn users, which is the
recommended configuration for the vast majority of sites.  It probably
affects Rainbows! users using Thread* or Revactor the most, and probably
some Unicorn users serving Intranet clients directly.

When clients are uploading large files, there's always a good
possibility of them disconnecting before the upload ends.  For other web
app servers it's not much of a problem: they read the entire upload
before attempting to process things; so the app never sees a prematurely
disconnected client.

However Rainbows! and Unicorn have the TeeInput class which allows
real-time processing of uploads as they occur.  Now, we _want_ the
exception to be thrown and application to stop processing the dead
client request immediately.  I've made changes in unicorn.git and
rainbows.git to ensure no EOFError exceptions from the socket are
silenced, not just ones from reading trailers.

However, this means (many more) socket errors will be seen within the
application and any global exception trappers they use will see them as
well.  For Rails (and possibly other frameworks), this can mean very
messy log files with large backtraces.

So, would making a Unicorn::Disconnect < EOFError exception class and
raising it with a short/empty backtrace on EOFErrors be the best way to
go?  That way those global exception trappers can distinguish between
EOFError exceptions raised by Unicorn/Rainbows! itself and other code
that Unicorn/Rainbows does not care about, and log appropriately...

The other option we have is catch/throw.  We can avoid worrying about
the stack trace entirely, and middlewares that opt-in can still capture
and log the disconnect if they want to.  More maintenance overhead for
Rainbows! with all its concurrency models, but this is a situation
where I think catch/throw is appropriate for given the current
middleware/application stacks these days.

Thanks for reading.

-- 
Eric Wong

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

end of thread, other threads:[~2009-11-14  1:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-11-12 10:04 dealing with client disconnects with TeeInput Eric Wong
2009-11-14  1:16 ` Eric Wong

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

	https://yhbt.net/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).