You are viewing a plain text version of this content. The canonical link for it is here.
Posted to httpclient-users@hc.apache.org by Tony Poppleton <to...@wanadoo.fr> on 2010/01/09 19:29:55 UTC
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
Re: Efficiently repeating identical requests
Posted by Ken Krugler <kk...@transpac.com>.
Hi Tony,
I'm assuming you can't just use more threads to reduce the average
inter-request delay, right?
-- Ken
On Jan 9, 2010, at 12:32pm, Tony Poppleton wrote:
> Hi Ken,
>
> It is for a financial application where fewer milliseconds = more
> money. I am trying to improve on the 3ms.
>
> Cheers,
> Tony
>
>> Message du 09/01/10 21:03
>> De : "Ken Krugler"
>> A : "HttpClient User Discussion"
>> Copie à :
>> Objet : Re: Efficiently repeating identical requests
>>
>>
>> Hi Tony,
>>
>> I'm wondering why you need to do this level of optimization - are you
>> running into issues with this type of POST request chewing up too
>> many
>> CPU cycles, and/or not being able to send the request every 3ms
>> because it's taking too long?
>>
>> -- Ken
>>
>> On Jan 9, 2010, at 10:29am, Tony Poppleton wrote:
>>
>>> 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
>>
>> --------------------------------------------
>> Ken Krugler
>> +1 530-210-6378
>> http://bixolabs.com
>> e l a s t i c w e b m i n i n g
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>> ---------------------------------------------------------------------------------------
>> 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.
>>
>>
>>
--------------------------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c w e b m i n i n g
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Efficiently repeating identical requests
Posted by Tony Poppleton <to...@wanadoo.fr>.
Hi Ken,
It is for a financial application where fewer milliseconds = more money. I am trying to improve on the 3ms.
Cheers,
Tony
> Message du 09/01/10 21:03
> De : "Ken Krugler"
> A : "HttpClient User Discussion"
> Copie à :
> Objet : Re: Efficiently repeating identical requests
>
>
> Hi Tony,
>
> I'm wondering why you need to do this level of optimization - are you
> running into issues with this type of POST request chewing up too many
> CPU cycles, and/or not being able to send the request every 3ms
> because it's taking too long?
>
> -- Ken
>
> On Jan 9, 2010, at 10:29am, Tony Poppleton wrote:
>
> > 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
>
> --------------------------------------------
> Ken Krugler
> +1 530-210-6378
> http://bixolabs.com
> e l a s t i c w e b m i n i n g
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
> ---------------------------------------------------------------------------------------
> 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.
>
>
>
Re: Efficiently repeating identical requests
Posted by Ken Krugler <kk...@transpac.com>.
Hi Tony,
I'm wondering why you need to do this level of optimization - are you
running into issues with this type of POST request chewing up too many
CPU cycles, and/or not being able to send the request every 3ms
because it's taking too long?
-- Ken
On Jan 9, 2010, at 10:29am, Tony Poppleton wrote:
> 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
--------------------------------------------
Ken Krugler
+1 530-210-6378
http://bixolabs.com
e l a s t i c w e b m i n i n g
---------------------------------------------------------------------
To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
Re: Efficiently repeating identical requests
Posted by Tony Poppleton <to...@wanadoo.fr>.
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: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
> ---------------------------------------------------------------------------------------
> 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.
>
>
>
Re: Efficiently repeating identical requests
Posted by Oleg Kalnichevski <ol...@apache.org>.
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: httpclient-users-unsubscribe@hc.apache.org
For additional commands, e-mail: httpclient-users-help@hc.apache.org
re: Efficiently repeating identical requests
Posted by Tony Poppleton <to...@wanadoo.fr>.
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
> 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.
>