You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cxf.apache.org by Daniel Kulp <dk...@apache.org> on 2012/09/04 21:03:37 UTC
Re: Async http client experiments....
Finally had a chance over the last week or so to re-dig into the async http stuff. You've probably seen a lot of commits and such related to it. :-)
Good news:
ALL of the CXF system tests now pass using it instead of the URLConnection based transport. I'm pretty excited about that as that's a huge milestone.
That said, there is still a bit of work todo:
1) Proxy support - haven't looked into this at all yet. Hard for me to test as well as I don't have any sort of proxy setup anywhere. I may need to look into how to setup a simple proxy to dig into this.
2) HTTPs Keep-Alive - right now, with HTTPs, a new connect is created for every request. With HTTPs, that's really expensive as it needs to do the handshakes and such for every request. This is next on my TODO to look at. One issue is that the BasicNIOConnPool really only compares the host name/port/scheme to determine connection re-use. Not any of the certs or anything like that. I'll need to implement a "state" object to handle checking a lot of that. Definitely next.
3) Configuration - now that things are working, I'll need to find a way to expose some configuration things. Specifically around things like number of connections to hold open, number per target/host, thread pools, etc….
4) Flip the logging and such to using our normal Logging framework.
5) Move it all from the sandbox to trunk.
Anyway, definitely getting closer. :-)
Dan
On Aug 6, 2012, at 10:43 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Fri, 2012-08-03 at 09:17 -0400, Daniel Kulp wrote:
>> On Friday, August 03, 2012 11:29:41 AM Oleg Kalnichevski wrote:
>>>> I just went through and added a little bit of error handling into it as
>>>> well. Mostly around a connection refused exception and for read
>>>> timeouts. For the read timeout, I DID have to add an ioct.shutdown() in
>>>> the SharedInBuffer consume method when read or it kept getting called
>>>> repeatedly since we didn't read anything.
>>>
>>> Hmmm. This should not be necessary. It is the responsibility of the
>>> protocol handler to shut down things properly if connection goes down or
>>> something breaks at runtime. In case of an I/O timeout the protocol
>>> handler always shuts down the execution handler, which in its turn
>>> should shut down shared i/o buffers [1]. I'll look into it.
>>
>> Well, it's mostly because I didn't actually set the timeouts on the
>> connection at all. Haven't figured that out yet mostly due to the same
>> issus as with the SSL/connection timeouts/etc... as we set them on a per-
>> request basis normally. For now so things don't "hang", I just added
>> timeouts on the wait(...) calls we use when we need to block for additional
>> IO. In that case, the wait(...) times out and I need to shutdown the
>> buffers and such manually so when the data DOES eventually arrive, we ignore
>> it. Setting the "real" timeouts on the connections would definitely help.
>>
>
>
> Hi Daniel
>
> I tweaked the code a bit to make sure i/o timeouts (both connect and
> receive ones) are handled correctly and can be specified on a per
> request basis overriding the defaults. Please review / verify.
>
> I also added connection pool lease / release logging. I am no longer
> seeing anything suspicious related to connection management. When
> executing requests sequentially the connection manager allocates one
> connection only.
>
>>>> CXF allows these to be configured on a per-client (and sometimes even
>>>> per- request) basis. It looks like HC seems to have these on the
>>>> connection factory.
>>>
>>> It does not have to be this way. Connections can start off as plain and
>>> later get upgraded to TLS/SSL by the protocol handling code. One would
>>> have to tweak the default protocol handler a bit, though, probably by
>>> overriding the HttpAsyncRequestExecutor#requestReady method [2].
>>
>> Ah. OK. I'll take a look there. I was looking in the various connection
>> factories and pools. Haven't looked there yet. Lots of stuff going on.
>> :-)
>>
>
> I also added a CXF specific connection manager implementation in order
> to enable SSL customization based on request configuration. However,
> before I proceed I would like to understand the requirements a little
> better. Can I assume that once an SSL connection has been fully set up
> using request level config parameters and can be pooled and safely
> reused for subsequent requests to the same service (even by different
> users) or requests may contain different / incompatible SSL
> configuration for the same service?
>
> Oleg
>
>
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
Re: Async http client experiments....
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2012-09-06 at 10:12 -0400, Daniel Kulp wrote:
> On Sep 6, 2012, at 9:40 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
> > On Wed, 2012-09-05 at 10:55 -0400, Daniel Kulp wrote:
> >> On Sep 5, 2012, at 9:35 AM, Alessio Soldano <as...@redhat.com> wrote:
> >>
> >>> On 09/04/2012 09:03 PM, Daniel Kulp wrote:
> >>>>
> >>>> That said, there is still a bit of work todo:
> >>>>
> >>>> 1) Proxy support - haven't looked into this at all yet. Hard for me to test as well as I don't have any sort of proxy setup anywhere. I may need to look into how to setup a simple proxy to dig into this.
> >>>
> >>> Not sure if this would be the best option for you, but some time ago I
> >>> wrote some JBossWS tests related to http proxy configuration by using
> >>> LittleProxy [1], perhaps it's convenient here too.
> >>>
> >>> [1] http://www.littleshoot.org/littleproxy/
> >>
> >> Cool. I see they just started a vote for 0.5 so if I wait a day or three, I can just start with the newer version. :-)
> >>
> >> Thanks for the pointer.
> >>
> >> Dan
> >>
> >
> > I personally use Squid [1] running locally in non-daemon mode to test
> > HttpClient against. It is one of the most widely used proxies around.
>
>
> I was originally looking at this, but there is a big disadvantage: it's external to the build. The nice thing about the littleproxy thing is in your junit tests, you can pop up a proxy on any port, use it, bring it down, etc… just like any other service we may be using. It would work on every developers machine.
>
> Right now, we have ZERO coverage of the proxy support in CXF, even for the HttpURLConnection based transport. With the little proxy thing, I'm hoping to rectify that. That said, I don't think it provides all the various possible proxy situations that squid can, but at this point, some tests are better than none. :-)
>
>
This is certainly a very valid point. Actually we are in the same boat.
Close to zero coverage of proxy code. And we have all the building
blocks necessary to put together a full blown caching proxy. The trouble
is that the _real_ troublemaker is never the proxy itself. In most cases
proxies are almost transparent to the client. The real ugly b**ch is
always a combination of HTTP proxy and authentication (either on the
proxy or the target side), especially NTLM, which is not very easy to
emulate.
Oleg
Re: Async http client experiments....
Posted by Alessio Soldano <as...@redhat.com>.
On 09/06/2012 04:12 PM, Daniel Kulp wrote:
>>
>> I personally use Squid [1] running locally in non-daemon mode to test
>> HttpClient against. It is one of the most widely used proxies around.
>
>
> I was originally looking at this, but there is a big disadvantage: it's external to the build. The nice thing about the littleproxy thing is in your junit tests, you can pop up a proxy on any port, use it, bring it down, etc… just like any other service we may be using. It would work on every developers machine.
+100, exactly my reasoning
Alessio
--
Alessio Soldano
Web Service Lead, JBoss
Re: Async http client experiments....
Posted by Daniel Kulp <dk...@apache.org>.
On Sep 6, 2012, at 9:40 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Wed, 2012-09-05 at 10:55 -0400, Daniel Kulp wrote:
>> On Sep 5, 2012, at 9:35 AM, Alessio Soldano <as...@redhat.com> wrote:
>>
>>> On 09/04/2012 09:03 PM, Daniel Kulp wrote:
>>>>
>>>> That said, there is still a bit of work todo:
>>>>
>>>> 1) Proxy support - haven't looked into this at all yet. Hard for me to test as well as I don't have any sort of proxy setup anywhere. I may need to look into how to setup a simple proxy to dig into this.
>>>
>>> Not sure if this would be the best option for you, but some time ago I
>>> wrote some JBossWS tests related to http proxy configuration by using
>>> LittleProxy [1], perhaps it's convenient here too.
>>>
>>> [1] http://www.littleshoot.org/littleproxy/
>>
>> Cool. I see they just started a vote for 0.5 so if I wait a day or three, I can just start with the newer version. :-)
>>
>> Thanks for the pointer.
>>
>> Dan
>>
>
> I personally use Squid [1] running locally in non-daemon mode to test
> HttpClient against. It is one of the most widely used proxies around.
I was originally looking at this, but there is a big disadvantage: it's external to the build. The nice thing about the littleproxy thing is in your junit tests, you can pop up a proxy on any port, use it, bring it down, etc… just like any other service we may be using. It would work on every developers machine.
Right now, we have ZERO coverage of the proxy support in CXF, even for the HttpURLConnection based transport. With the little proxy thing, I'm hoping to rectify that. That said, I don't think it provides all the various possible proxy situations that squid can, but at this point, some tests are better than none. :-)
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
Re: Async http client experiments....
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Wed, 2012-09-05 at 10:55 -0400, Daniel Kulp wrote:
> On Sep 5, 2012, at 9:35 AM, Alessio Soldano <as...@redhat.com> wrote:
>
> > On 09/04/2012 09:03 PM, Daniel Kulp wrote:
> >>
> >> That said, there is still a bit of work todo:
> >>
> >> 1) Proxy support - haven't looked into this at all yet. Hard for me to test as well as I don't have any sort of proxy setup anywhere. I may need to look into how to setup a simple proxy to dig into this.
> >
> > Not sure if this would be the best option for you, but some time ago I
> > wrote some JBossWS tests related to http proxy configuration by using
> > LittleProxy [1], perhaps it's convenient here too.
> >
> > [1] http://www.littleshoot.org/littleproxy/
>
> Cool. I see they just started a vote for 0.5 so if I wait a day or three, I can just start with the newer version. :-)
>
> Thanks for the pointer.
>
> Dan
>
I personally use Squid [1] running locally in non-daemon mode to test
HttpClient against. It is one of the most widely used proxies around.
Oleg
[1] http://en.wikipedia.org/wiki/Squid_%28software%29
> >
> > Cheers
> > Alessio
> >
> > --
> > Alessio Soldano
> > Web Service Lead, JBoss
>
Re: Async http client experiments....
Posted by Daniel Kulp <dk...@apache.org>.
On Sep 5, 2012, at 9:35 AM, Alessio Soldano <as...@redhat.com> wrote:
> On 09/04/2012 09:03 PM, Daniel Kulp wrote:
>>
>> That said, there is still a bit of work todo:
>>
>> 1) Proxy support - haven't looked into this at all yet. Hard for me to test as well as I don't have any sort of proxy setup anywhere. I may need to look into how to setup a simple proxy to dig into this.
>
> Not sure if this would be the best option for you, but some time ago I
> wrote some JBossWS tests related to http proxy configuration by using
> LittleProxy [1], perhaps it's convenient here too.
>
> [1] http://www.littleshoot.org/littleproxy/
Cool. I see they just started a vote for 0.5 so if I wait a day or three, I can just start with the newer version. :-)
Thanks for the pointer.
Dan
>
> Cheers
> Alessio
>
> --
> Alessio Soldano
> Web Service Lead, JBoss
--
Daniel Kulp
dkulp@apache.org - http://dankulp.com/blog
Talend Community Coder - http://coders.talend.com
Re: Async http client experiments....
Posted by Alessio Soldano <as...@redhat.com>.
On 09/04/2012 09:03 PM, Daniel Kulp wrote:
>
> That said, there is still a bit of work todo:
>
> 1) Proxy support - haven't looked into this at all yet. Hard for me to test as well as I don't have any sort of proxy setup anywhere. I may need to look into how to setup a simple proxy to dig into this.
Not sure if this would be the best option for you, but some time ago I
wrote some JBossWS tests related to http proxy configuration by using
LittleProxy [1], perhaps it's convenient here too.
[1] http://www.littleshoot.org/littleproxy/
Cheers
Alessio
--
Alessio Soldano
Web Service Lead, JBoss
Re: Async http client experiments....
Posted by Oleg Kalnichevski <ol...@apache.org>.
On Tue, 2012-09-04 at 15:03 -0400, Daniel Kulp wrote:
> Finally had a chance over the last week or so to re-dig into the async http stuff. You've probably seen a lot of commits and such related to it. :-)
>
> Good news:
> ALL of the CXF system tests now pass using it instead of the URLConnection based transport. I'm pretty excited about that as that's a huge milestone.
>
Hi Dan
I am glad things are shaping up well.
> That said, there is still a bit of work todo:
>
> 1) Proxy support - haven't looked into this at all yet. Hard for me to test as well as I don't have any sort of proxy setup anywhere. I may need to look into how to setup a simple proxy to dig into this.
>
> 2) HTTPs Keep-Alive - right now, with HTTPs, a new connect is created for every request. With HTTPs, that's really expensive as it needs to do the handshakes and such for every request. This is next on my TODO to look at. One issue is that the BasicNIOConnPool really only compares the host name/port/scheme to determine connection re-use. Not any of the certs or anything like that. I'll need to implement a "state" object to handle checking a lot of that. Definitely next.
>
> 3) Configuration - now that things are working, I'll need to find a way to expose some configuration things. Specifically around things like number of connections to hold open, number per target/host, thread pools, etc….
>
> 4) Flip the logging and such to using our normal Logging framework.
>
> 5) Move it all from the sandbox to trunk.
>
>
> Anyway, definitely getting closer. :-)
>
I am completely buried under with work at my day job (the one that helps
me pay the bills) and am unlikely to be able to find a lot of time to
write code but will happily assist with HC specific issues. Just let me
know.
Cheers
Oleg
>
> Dan
>
>
>
> On Aug 6, 2012, at 10:43 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
>
> > On Fri, 2012-08-03 at 09:17 -0400, Daniel Kulp wrote:
> >> On Friday, August 03, 2012 11:29:41 AM Oleg Kalnichevski wrote:
> >>>> I just went through and added a little bit of error handling into it as
> >>>> well. Mostly around a connection refused exception and for read
> >>>> timeouts. For the read timeout, I DID have to add an ioct.shutdown() in
> >>>> the SharedInBuffer consume method when read or it kept getting called
> >>>> repeatedly since we didn't read anything.
> >>>
> >>> Hmmm. This should not be necessary. It is the responsibility of the
> >>> protocol handler to shut down things properly if connection goes down or
> >>> something breaks at runtime. In case of an I/O timeout the protocol
> >>> handler always shuts down the execution handler, which in its turn
> >>> should shut down shared i/o buffers [1]. I'll look into it.
> >>
> >> Well, it's mostly because I didn't actually set the timeouts on the
> >> connection at all. Haven't figured that out yet mostly due to the same
> >> issus as with the SSL/connection timeouts/etc... as we set them on a per-
> >> request basis normally. For now so things don't "hang", I just added
> >> timeouts on the wait(...) calls we use when we need to block for additional
> >> IO. In that case, the wait(...) times out and I need to shutdown the
> >> buffers and such manually so when the data DOES eventually arrive, we ignore
> >> it. Setting the "real" timeouts on the connections would definitely help.
> >>
> >
> >
> > Hi Daniel
> >
> > I tweaked the code a bit to make sure i/o timeouts (both connect and
> > receive ones) are handled correctly and can be specified on a per
> > request basis overriding the defaults. Please review / verify.
> >
> > I also added connection pool lease / release logging. I am no longer
> > seeing anything suspicious related to connection management. When
> > executing requests sequentially the connection manager allocates one
> > connection only.
> >
> >>>> CXF allows these to be configured on a per-client (and sometimes even
> >>>> per- request) basis. It looks like HC seems to have these on the
> >>>> connection factory.
> >>>
> >>> It does not have to be this way. Connections can start off as plain and
> >>> later get upgraded to TLS/SSL by the protocol handling code. One would
> >>> have to tweak the default protocol handler a bit, though, probably by
> >>> overriding the HttpAsyncRequestExecutor#requestReady method [2].
> >>
> >> Ah. OK. I'll take a look there. I was looking in the various connection
> >> factories and pools. Haven't looked there yet. Lots of stuff going on.
> >> :-)
> >>
> >
> > I also added a CXF specific connection manager implementation in order
> > to enable SSL customization based on request configuration. However,
> > before I proceed I would like to understand the requirements a little
> > better. Can I assume that once an SSL connection has been fully set up
> > using request level config parameters and can be pooled and safely
> > reused for subsequent requests to the same service (even by different
> > users) or requests may contain different / incompatible SSL
> > configuration for the same service?
> >
> > Oleg
> >
> >
>