You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Garth Patil <ga...@gmail.com> on 2006/03/25 03:13:14 UTC

NIO

Hi,
Sorry if this should've been posted to the user list. I'm interested
in knowing the basis for the following statement on this page:
http://jakarta.apache.org/httpcomponents/http-nio.html

"NIO model proved inferior to the classic IO model in terms of raw
performance for blocking HTTP implementations that is where the
content is meant to be produced / consumed using standard
java.io.OutputStream / java.io.InputStream interfaces such as Servlet
API.
HttpNIO will provide an event driven, non-blocking implementation of
HTTP protocol for those use scenarios where raw throughput is less
important than ability to handle a significant number of simultaneous
HTTP connections in a resource efficient manner."

I ask because I have implemented a variety of HTTP client logic for
spiders and page fetchers (in java.io, java.nio, or Python's
asyncore), and I've seen a variety of results based on the
implementation. Do folks have benchmarks and example code that show
the relative merits of different approaches they've tried?

Thanks,
Garth

---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org


Re: NIO

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2006-03-24 at 18:13 -0800, Garth Patil wrote:
> Hi,
> Sorry if this should've been posted to the user list. I'm interested
> in knowing the basis for the following statement on this page:
> http://jakarta.apache.org/httpcomponents/http-nio.html
> 
> "NIO model proved inferior to the classic IO model in terms of raw
> performance for blocking HTTP implementations that is where the
> content is meant to be produced / consumed using standard
> java.io.OutputStream / java.io.InputStream interfaces such as Servlet
> API.
> HttpNIO will provide an event driven, non-blocking implementation of
> HTTP protocol for those use scenarios where raw throughput is less
> important than ability to handle a significant number of simultaneous
> HTTP connections in a resource efficient manner."
> 
> I ask because I have implemented a variety of HTTP client logic for
> spiders and page fetchers (in java.io, java.nio, or Python's
> asyncore), and I've seen a variety of results based on the
> implementation. Do folks have benchmarks and example code that show
> the relative merits of different approaches they've tried?
> 

Garth,

I have invested over several months into looking at how we could use NIO
in HttpCore and HttpClient 4.x. All related discussions, code samples,
and benchmark results can be found in the email archives. 

To make a rather long story short, NIO simply makes no sense when used
in the classic blocking I/O model based on InputStream/OutputStream
interfaces. The classic I/O model essentially requires one selector per
channel, which is simply too wasteful and slow. NIO stats paying off
only when one can use one selector to manage dozens of channels 

Hope this clarifies it sonmewhat

Oleg


> Thanks,
> Garth
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: httpclient-dev-help@jakarta.apache.org