Implement non blocking read on HTTP requests.
authorfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 18 Oct 2006 23:24:52 +0000 (23:24 +0000)
committerfhanik <fhanik@13f79535-47bb-0310-9956-ffa450edef68>
Wed, 18 Oct 2006 23:24:52 +0000 (23:24 +0000)
commitc0395900664dab4138b6ae0fbb896942b64dbe55
tree7e40e16730a25d003d271e6c1cca74c24ed82d0f
parentc12f7acaf65bdb8a01569d4fad95afab1b2792c3
Implement non blocking read on HTTP requests.

A common scalability problem when it comes to HTTP is the fact that there are slow clients, that will block a server resources while sending a HTTP request. Especially when you have larger request headers.

On FreeBSD the kernel has a built in http filter to not wake up the application socket handle until the entire request has been received, however on other platforms this is not available.

With the Tomcat connectors, there is an obvious problem when it comes to slow clients, if the client sends up a partial request, Tomcat will block the thread until the client has finished sending the request. For example, if the client has 10 headers it sends up the first 5 headers, then the next 5 in a sequential batch, the tomcat thread is locked in a blocking read
I've tried to fix that problem by making the NIO connector be non blocking. The only time the NIO connector will block now is when the servlet asks for data, usually the request body, as we don't have a way to suspend a thread, like continuations.
Once we have continuations(that can truly remember thread stack data), we can have a truly non blocking server, but we are not there yet.

I believe this code could be easily ported to APR connector with very little effort.
When you review this code, please note that I have not attemtped to rewrite the header parse logic, I might do that in a later stage as this got a little messy, but I wanted the proof of concept done first and reuse as much code as possible.

Please feel free to review and even flame me if needed, at least that means this got some attention :)

git-svn-id: https://svn.apache.org/repos/asf/tomcat/tc6.0.x/trunk@465417 13f79535-47bb-0310-9956-ffa450edef68
java/org/apache/coyote/http11/Http11NioProcessor.java
java/org/apache/coyote/http11/InternalNioInputBuffer.java