Best way to deal with long-running requests?

86 views
Skip to first unread message

Ryan Noon

unread,
Nov 20, 2012, 7:46:31 PM11/20/12
to web...@googlegroups.com
Hi everybody,

I'm kinda new to async web servers.  I just started playing with webbit (via webbit-rest) and I'm having difficulty in processing simultaneous requests that take a while.

I know I'm not supposed to block in the handler, so I wrote an example like this:


In this case, I'm creating a worker thread to simulate doing something expensive (like a DB call) and I'm passing a runnable to the NettyServer's executor when done to set the response body and "end" it.

However, when I make two requests at the same time, the spread across them is 4 seconds (instead of the expected 2), even though the handleHttpRequest method in both returns immediately.  Is there any way to get the webbit server to do two things at once, or must all requests be processed entirely in-order?

Ryan Noon

unread,
Nov 21, 2012, 7:14:34 AM11/21/12
to web...@googlegroups.com
Ok, so I figured it out and the answer is quite stupid.  Everything's fine with webbit.

It's a Chrome HTTP optimization.  It will queue up requests from different tabs/windows for the same URL so as to only actually have 1 in flight at a time.  Doing the request manually with telnet worked just fine.

Lesson: avoid debugging a complicated piece of software with an even more complicated piece of software.

aslak hellesoy

unread,
Nov 21, 2012, 7:25:40 AM11/21/12
to Webbit
On Wed, Nov 21, 2012 at 12:14 PM, Ryan Noon <rmn...@gmail.com> wrote:
Ok, so I figured it out and the answer is quite stupid.  Everything's fine with webbit.

It's a Chrome HTTP optimization.  It will queue up requests from different tabs/windows for the same URL so as to only actually have 1 in flight at a time.  Doing the request manually with telnet worked just fine.

Lesson: avoid debugging a complicated piece of software with an even more complicated piece of software.

Thanks for the update Ryan. I did take a glance at your code and nothing wrong jumped out at me. Glad you found the cause.

Aslak
Reply all
Reply to author
Forward
0 new messages