You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@hc.apache.org by Marc Larue <ma...@rupy.se> on 2014/10/02 19:37:04 UTC

NIO Selector client

Hi,

Have you considered writing a single threaded selector.select() driven 
HTTP client?

This would be very efficient and allow for Java HTTP load balancing!

Kind Regards,

/marc

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


Re: NIO Selector client

Posted by Marc Larue <ma...@rupy.se>.
Aha!

Looks good!

I'll try to make sure our groovy code ends up using that code...

Thanks,

/m

On Fri, 3 Oct 2014, Oleg Kalnichevski wrote:

> On Fri, 2014-10-03 at 16:04 +0200, Marc Larue wrote:
>> Ok, but how does it handle say 10.000 concurrent async requests on those
>> few threads?
>>
>> Trying to read the code, but it's so abstract I can't find the inner
>> workings...
>>
>
> https://github.com/apache/httpcore/tree/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor
>
> Oleg
>
>> /m
>>
>> On Fri, 3 Oct 2014, Oleg Kalnichevski wrote:
>>
>>> On Fri, 2014-10-03 at 15:31 +0200, Marc Larue wrote:
>>>> Hi Oleg,
>>>>
>>>> I'm guessing that the HAC uses many threads for async/concurrency?
>>>>
>>>> If you use a selector, you can async all requests on the network layer
>>>> instead of a thread pool, which scales alot better.
>>>>
>>>> But maybe thats allready how HAC works? I searched the code for 'selector'
>>>> but couldn't find any.
>>>>
>>>
>>> HttpAsyncClient uses the same number of I/O dispatch threads as physical
>>> CPU cores by default, but one can force it to use one thread only.
>>>
>>> Oleg
>>>
>>>
>>>> Kind Regards,
>>>>
>>>> /marc
>>>>
>>>> On Fri, 3 Oct 2014, Oleg Kalnichevski wrote:
>>>>
>>>>> On Thu, 2014-10-02 at 19:37 +0200, Marc Larue wrote:
>>>>>> Hi,
>>>>>>
>>>>>> Have you considered writing a single threaded selector.select() driven
>>>>>> HTTP client?
>>>>>>
>>>>>
>>>>> Marc,
>>>>>
>>>>> I am not sure I understand. How exactly would that differ from
>>>>> HttpAsyncClient?
>>>>>
>>>>> http://hc.apache.org/httpcomponents-asyncclient-4.0.x/index.html
>>>>>
>>>>> Oleg
>>>>>
>>>>>> This would be very efficient and allow for Java HTTP load balancing!
>>>>>>
>>>>>> Kind Regards,
>>>>>>
>>>>>> /marc
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>>>>>> For additional commands, e-mail: dev-help@hc.apache.org
>>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>>>>> For additional commands, e-mail: dev-help@hc.apache.org
>>>>>
>>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>>>> For additional commands, e-mail: dev-help@hc.apache.org
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: dev-help@hc.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>> For additional commands, e-mail: dev-help@hc.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>

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


Re: NIO Selector client

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2014-10-03 at 16:04 +0200, Marc Larue wrote:
> Ok, but how does it handle say 10.000 concurrent async requests on those 
> few threads?
> 
> Trying to read the code, but it's so abstract I can't find the inner 
> workings...
> 

https://github.com/apache/httpcore/tree/trunk/httpcore-nio/src/main/java/org/apache/http/impl/nio/reactor

Oleg

> /m
> 
> On Fri, 3 Oct 2014, Oleg Kalnichevski wrote:
> 
> > On Fri, 2014-10-03 at 15:31 +0200, Marc Larue wrote:
> >> Hi Oleg,
> >>
> >> I'm guessing that the HAC uses many threads for async/concurrency?
> >>
> >> If you use a selector, you can async all requests on the network layer
> >> instead of a thread pool, which scales alot better.
> >>
> >> But maybe thats allready how HAC works? I searched the code for 'selector'
> >> but couldn't find any.
> >>
> >
> > HttpAsyncClient uses the same number of I/O dispatch threads as physical
> > CPU cores by default, but one can force it to use one thread only.
> >
> > Oleg
> >
> >
> >> Kind Regards,
> >>
> >> /marc
> >>
> >> On Fri, 3 Oct 2014, Oleg Kalnichevski wrote:
> >>
> >>> On Thu, 2014-10-02 at 19:37 +0200, Marc Larue wrote:
> >>>> Hi,
> >>>>
> >>>> Have you considered writing a single threaded selector.select() driven
> >>>> HTTP client?
> >>>>
> >>>
> >>> Marc,
> >>>
> >>> I am not sure I understand. How exactly would that differ from
> >>> HttpAsyncClient?
> >>>
> >>> http://hc.apache.org/httpcomponents-asyncclient-4.0.x/index.html
> >>>
> >>> Oleg
> >>>
> >>>> This would be very efficient and allow for Java HTTP load balancing!
> >>>>
> >>>> Kind Regards,
> >>>>
> >>>> /marc
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> >>>> For additional commands, e-mail: dev-help@hc.apache.org
> >>>>
> >>>
> >>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> >>> For additional commands, e-mail: dev-help@hc.apache.org
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> >> For additional commands, e-mail: dev-help@hc.apache.org
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> > For additional commands, e-mail: dev-help@hc.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
> 



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


Re: NIO Selector client

Posted by Marc Larue <ma...@rupy.se>.
Ok, but how does it handle say 10.000 concurrent async requests on those 
few threads?

Trying to read the code, but it's so abstract I can't find the inner 
workings...

/m

On Fri, 3 Oct 2014, Oleg Kalnichevski wrote:

> On Fri, 2014-10-03 at 15:31 +0200, Marc Larue wrote:
>> Hi Oleg,
>>
>> I'm guessing that the HAC uses many threads for async/concurrency?
>>
>> If you use a selector, you can async all requests on the network layer
>> instead of a thread pool, which scales alot better.
>>
>> But maybe thats allready how HAC works? I searched the code for 'selector'
>> but couldn't find any.
>>
>
> HttpAsyncClient uses the same number of I/O dispatch threads as physical
> CPU cores by default, but one can force it to use one thread only.
>
> Oleg
>
>
>> Kind Regards,
>>
>> /marc
>>
>> On Fri, 3 Oct 2014, Oleg Kalnichevski wrote:
>>
>>> On Thu, 2014-10-02 at 19:37 +0200, Marc Larue wrote:
>>>> Hi,
>>>>
>>>> Have you considered writing a single threaded selector.select() driven
>>>> HTTP client?
>>>>
>>>
>>> Marc,
>>>
>>> I am not sure I understand. How exactly would that differ from
>>> HttpAsyncClient?
>>>
>>> http://hc.apache.org/httpcomponents-asyncclient-4.0.x/index.html
>>>
>>> Oleg
>>>
>>>> This would be very efficient and allow for Java HTTP load balancing!
>>>>
>>>> Kind Regards,
>>>>
>>>> /marc
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>>>> For additional commands, e-mail: dev-help@hc.apache.org
>>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: dev-help@hc.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>> For additional commands, e-mail: dev-help@hc.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>

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


Re: NIO Selector client

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Fri, 2014-10-03 at 15:31 +0200, Marc Larue wrote:
> Hi Oleg,
> 
> I'm guessing that the HAC uses many threads for async/concurrency?
> 
> If you use a selector, you can async all requests on the network layer 
> instead of a thread pool, which scales alot better.
> 
> But maybe thats allready how HAC works? I searched the code for 'selector' 
> but couldn't find any.
> 

HttpAsyncClient uses the same number of I/O dispatch threads as physical
CPU cores by default, but one can force it to use one thread only.

Oleg


> Kind Regards,
> 
> /marc
> 
> On Fri, 3 Oct 2014, Oleg Kalnichevski wrote:
> 
> > On Thu, 2014-10-02 at 19:37 +0200, Marc Larue wrote:
> >> Hi,
> >>
> >> Have you considered writing a single threaded selector.select() driven
> >> HTTP client?
> >>
> >
> > Marc,
> >
> > I am not sure I understand. How exactly would that differ from
> > HttpAsyncClient?
> >
> > http://hc.apache.org/httpcomponents-asyncclient-4.0.x/index.html
> >
> > Oleg
> >
> >> This would be very efficient and allow for Java HTTP load balancing!
> >>
> >> Kind Regards,
> >>
> >> /marc
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> >> For additional commands, e-mail: dev-help@hc.apache.org
> >>
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> > For additional commands, e-mail: dev-help@hc.apache.org
> >
> >
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
> 



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


Re: NIO Selector client

Posted by Marc Larue <ma...@rupy.se>.
Hi Oleg,

I'm guessing that the HAC uses many threads for async/concurrency?

If you use a selector, you can async all requests on the network layer 
instead of a thread pool, which scales alot better.

But maybe thats allready how HAC works? I searched the code for 'selector' 
but couldn't find any.

Kind Regards,

/marc

On Fri, 3 Oct 2014, Oleg Kalnichevski wrote:

> On Thu, 2014-10-02 at 19:37 +0200, Marc Larue wrote:
>> Hi,
>>
>> Have you considered writing a single threaded selector.select() driven
>> HTTP client?
>>
>
> Marc,
>
> I am not sure I understand. How exactly would that differ from
> HttpAsyncClient?
>
> http://hc.apache.org/httpcomponents-asyncclient-4.0.x/index.html
>
> Oleg
>
>> This would be very efficient and allow for Java HTTP load balancing!
>>
>> Kind Regards,
>>
>> /marc
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
>> For additional commands, e-mail: dev-help@hc.apache.org
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
>
>

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


Re: NIO Selector client

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2014-10-02 at 19:37 +0200, Marc Larue wrote:
> Hi,
> 
> Have you considered writing a single threaded selector.select() driven 
> HTTP client?
> 

Marc,

I am not sure I understand. How exactly would that differ from
HttpAsyncClient?

http://hc.apache.org/httpcomponents-asyncclient-4.0.x/index.html

Oleg

> This would be very efficient and allow for Java HTTP load balancing!
> 
> Kind Regards,
> 
> /marc
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org
> For additional commands, e-mail: dev-help@hc.apache.org
> 



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