Hi,

Reviving this thread from a while ago, I have confirmed Oleg's comments about 
NIO being slower for raw throughput on a single socket (even using direct 
buffers).

I have attached a messy benchmark class to demonstrate if anyone else is 
interested, which uses a local echo server to respond to two clients; a regular 
socket client and an NIO client.

Regards,
Tony

> Message du 09/01/10 22:53
> De : "Oleg Kalnichevski" 
> A : "HttpClient User Discussion" 
> Copie à : 
> Objet : Re: Efficiently repeating identical requests
> 
> 
> Tony Poppleton wrote:
> > Hi,
> > 
> > Further to the previous mail, I have already implemented my own 
> > AbstractHttpEntity to eliminate a byte[] copy. And I have seen the NIO 
> > implementations of HttpEntities, however they don't seem to copy using NIO 
> > methods so they won't be any faster than the standard IO implementations.
> > 
> > Anyway, it seems I have to go a level deeper than this class to be able to 
> > do the NIO copy. Is this the right direction to be digging in?
> > 
> > Thanks,
> > Tony
> > 
> 
> Tony
> 
> Contrary to a common misconception, NIO is significantly slower than the 
> classic blocking I/O in terms of raw data throughput. Modern operating 
> systems and JVMs have become pretty efficient at switching thread 
> contexts. Connection multiplexing starts paying off only when the number 
> of concurrent connections exceeds 2000 or direct data streaming from or 
> to a file is used.
> 
> In other words, NIO on the client side makes sense only if one wants a 
> fully asynchronous processing model for a reason other than just 
> performance. Overall, I personally think NIO is not very useful for 
> client side HTTP. However, if you are interested in experimenting with 
> NIO copy operations, you could give HttpCore NIO a try:
> 
> http://hc.apache.org/httpcomponents-core/tutorial/html/nio.html
> http://hc.apache.org/httpcomponents-core/tutorial/html/nio.html#d0e1686
> 
> Hope this helps
> 
> Oleg
> 
> > 
> >> Message du 09/01/10 19:30
> >> De : "Tony Poppleton" 
> >> A : "HttpClient User Discussion [HttpClient User Discussion]" 
> >> Copie à : 
> >> Objet : Efficiently repeating identical requests
> >>
> >> Hi,
> >>
> >> I send out the exact same HttpPost request every 3 milliseconds and would 
> >> like to optimize it.
> >>
> >> As the POST data is exactly the same, I would like to hold it in a direct 
> >> ByteBuffer so it is in the kernel memory, and then use the efficient NIO 
> >> transfer methods to send it to the socket. Is this possible with 
> >> HttpClient, and if so how would I go about implementing this?
> >>
> >> Many thanks,
> >> Tony
> >>
> >> ---------------------------------------------------------------------------------------
> >>  Orange vous informe que cet e-mail a ete controle par l'anti-virus mail. 
> >> Aucun virus connu a ce jour par nos services n'a ete detecte. 
> >>
> > 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
> 
> ---------------------------------------------------------------------------------------
> Orange vous informe que cet e-mail a ete controle par l'anti-virus mail. 
> Aucun virus connu a ce jour par nos services n'a ete detecte.
> 
> 
> 
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to