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 Dan Checkoway <dc...@gmail.com> on 2011/05/27 02:17:27 UTC

looking for reliable failover pattern

Hello,

I'm looking for recommendations on best practice for client side
failover...with pooling/keepalive.  I've been rolling my own, but I'm
migrating to HC and could use some advice.  Here's what I'm faced with
requirements-wise:

1. My app is running on appserver01...n, and it's using HttpClient to
talk to a web service that's running on ws01...n.

2. Unfortunately, my hands are tied and I can't throw a VIP/LB in
front of ws01...n (wouldn't that just be too easy), and I can't use
round-robin DNS either (I found MultihomePlainSocketFactory, but it's
deprecated anyway).  I need to address the ws* boxes individually.

3. A key requirement is that I take advantage of persistent HTTP
connections (keepalive).

4. When appserverN needs to talk to ws*, it should pick a node at
random (poor man's load balancing).  If that node is down, it needs to
fail over to another node, without the calling code knowing or caring
what happened.

Is there a reliable existing pattern or example out there somewhere,
or -- better yet -- something in HttpCore or HttpClient that provides
this type of pooling with failover strategy out of the box?  I would
rather steal or adapt good code than reinvent this wheel...

Any tips?

Thanks,
Dan

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


Re: looking for reliable failover pattern

Posted by Dan Checkoway <dc...@gmail.com>.
Thanks guys.

What I'm *really* after here is "best practice" for releasing
resources on failed nodes and what not.  i.e. I'm writing my own retry
"loop" that iterates through the available nodes, and when one throws
an exception (i.e. connection failed), I want to make sure I'm not
creating resource leaks by being careless.

Dan

On Sun, May 29, 2011 at 7:35 AM, Ryan Smith <ry...@gmail.com> wrote:
> Sorry, the email got sent before I finished.  I was just going to implement
> a blocked ip list for you but then I realized how easy it was.  It shouldnt
> be too hard to implement the blacklist.
> Good luck!
>
> On Sun, May 29, 2011 at 7:34 AM, Ryan Smith <ry...@gmail.com>wrote:
>
>> List<String> blacklistedIPs = new ArrayList<String>();
>>
>> if (!isIpAvailable(myIP)) {
>>     if () {
>>
>>
>>     }
>> }
>>
>> On Sat, May 28, 2011 at 12:51 PM, Dan Checkoway <dc...@gmail.com>wrote:
>>
>>> Ok, thanks.  So it does sound like I'm going to need to roll my own.
>>> No existing examples of this out there already?  i.e. something that
>>> maintains pools of HttpClient objects or whatever, and does retry
>>> periodically after failover, using expoential backoff, or what not.
>>>
>>> No problem rolling my own, but I'd love to reuse somebody else's hard
>>> work if possible.  :-)
>>>
>>> Dan
>>>
>>> On Sat, May 28, 2011 at 12:44 PM, Oleg Kalnichevski <ol...@apache.org>
>>> wrote:
>>> > On Sat, 2011-05-28 at 12:37 -0400, Dan Checkoway wrote:
>>> >> Oleg,
>>> >>
>>> >> Thanks for the reply.  Ideally the "spray" approach is what I'm looking
>>> for.
>>> >>
>>> >> Dan
>>> >
>>> > Dan,
>>> >
>>> > This is not supported out of the box but should not be that difficult to
>>> > implement. You just need to maintain a list of IP addresses or hostnames
>>> > and be able to temporarily 'blacklist' those that do not respond.
>>> >
>>> > Oleg
>>> >
>>> >
>>> > ---------------------------------------------------------------------
>>> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>> >
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>>
>>>
>>
>

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


Re: looking for reliable failover pattern

Posted by Ryan Smith <ry...@gmail.com>.
Sorry, the email got sent before I finished.  I was just going to implement
a blocked ip list for you but then I realized how easy it was.  It shouldnt
be too hard to implement the blacklist.
Good luck!

On Sun, May 29, 2011 at 7:34 AM, Ryan Smith <ry...@gmail.com>wrote:

> List<String> blacklistedIPs = new ArrayList<String>();
>
> if (!isIpAvailable(myIP)) {
>     if () {
>
>
>     }
> }
>
> On Sat, May 28, 2011 at 12:51 PM, Dan Checkoway <dc...@gmail.com>wrote:
>
>> Ok, thanks.  So it does sound like I'm going to need to roll my own.
>> No existing examples of this out there already?  i.e. something that
>> maintains pools of HttpClient objects or whatever, and does retry
>> periodically after failover, using expoential backoff, or what not.
>>
>> No problem rolling my own, but I'd love to reuse somebody else's hard
>> work if possible.  :-)
>>
>> Dan
>>
>> On Sat, May 28, 2011 at 12:44 PM, Oleg Kalnichevski <ol...@apache.org>
>> wrote:
>> > On Sat, 2011-05-28 at 12:37 -0400, Dan Checkoway wrote:
>> >> Oleg,
>> >>
>> >> Thanks for the reply.  Ideally the "spray" approach is what I'm looking
>> for.
>> >>
>> >> Dan
>> >
>> > Dan,
>> >
>> > This is not supported out of the box but should not be that difficult to
>> > implement. You just need to maintain a list of IP addresses or hostnames
>> > and be able to temporarily 'blacklist' those that do not respond.
>> >
>> > Oleg
>> >
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
>> >
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
>> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>>
>>
>

Re: looking for reliable failover pattern

Posted by Ryan Smith <ry...@gmail.com>.
List<String> blacklistedIPs = new ArrayList<String>();

if (!isIpAvailable(myIP)) {
    if () {

    }
}

On Sat, May 28, 2011 at 12:51 PM, Dan Checkoway <dc...@gmail.com>wrote:

> Ok, thanks.  So it does sound like I'm going to need to roll my own.
> No existing examples of this out there already?  i.e. something that
> maintains pools of HttpClient objects or whatever, and does retry
> periodically after failover, using expoential backoff, or what not.
>
> No problem rolling my own, but I'd love to reuse somebody else's hard
> work if possible.  :-)
>
> Dan
>
> On Sat, May 28, 2011 at 12:44 PM, Oleg Kalnichevski <ol...@apache.org>
> wrote:
> > On Sat, 2011-05-28 at 12:37 -0400, Dan Checkoway wrote:
> >> Oleg,
> >>
> >> Thanks for the reply.  Ideally the "spray" approach is what I'm looking
> for.
> >>
> >> Dan
> >
> > Dan,
> >
> > This is not supported out of the box but should not be that difficult to
> > implement. You just need to maintain a list of IP addresses or hostnames
> > and be able to temporarily 'blacklist' those that do not respond.
> >
> > Oleg
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> > For additional commands, e-mail: httpclient-users-help@hc.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

Re: looking for reliable failover pattern

Posted by Dan Checkoway <dc...@gmail.com>.
Ok, thanks.  So it does sound like I'm going to need to roll my own.
No existing examples of this out there already?  i.e. something that
maintains pools of HttpClient objects or whatever, and does retry
periodically after failover, using expoential backoff, or what not.

No problem rolling my own, but I'd love to reuse somebody else's hard
work if possible.  :-)

Dan

On Sat, May 28, 2011 at 12:44 PM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Sat, 2011-05-28 at 12:37 -0400, Dan Checkoway wrote:
>> Oleg,
>>
>> Thanks for the reply.  Ideally the "spray" approach is what I'm looking for.
>>
>> Dan
>
> Dan,
>
> This is not supported out of the box but should not be that difficult to
> implement. You just need to maintain a list of IP addresses or hostnames
> and be able to temporarily 'blacklist' those that do not respond.
>
> Oleg
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

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


Re: looking for reliable failover pattern

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Sat, 2011-05-28 at 12:37 -0400, Dan Checkoway wrote:
> Oleg,
> 
> Thanks for the reply.  Ideally the "spray" approach is what I'm looking for.
> 
> Dan

Dan,

This is not supported out of the box but should not be that difficult to
implement. You just need to maintain a list of IP addresses or hostnames
and be able to temporarily 'blacklist' those that do not respond.

Oleg   


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


Re: looking for reliable failover pattern

Posted by Dan Checkoway <dc...@gmail.com>.
Oleg,

Thanks for the reply.  Ideally the "spray" approach is what I'm looking for.

Dan

On Sat, May 28, 2011 at 11:47 AM, Oleg Kalnichevski <ol...@apache.org> wrote:
> On Thu, 2011-05-26 at 20:17 -0400, Dan Checkoway wrote:
>> Hello,
>>
>> I'm looking for recommendations on best practice for client side
>> failover...with pooling/keepalive.  I've been rolling my own, but I'm
>> migrating to HC and could use some advice.  Here's what I'm faced with
>> requirements-wise:
>>
>> 1. My app is running on appserver01...n, and it's using HttpClient to
>> talk to a web service that's running on ws01...n.
>>
>> 2. Unfortunately, my hands are tied and I can't throw a VIP/LB in
>> front of ws01...n (wouldn't that just be too easy), and I can't use
>> round-robin DNS either (I found MultihomePlainSocketFactory, but it's
>> deprecated anyway).  I need to address the ws* boxes individually.
>>
>> 3. A key requirement is that I take advantage of persistent HTTP
>> connections (keepalive).
>>
>> 4. When appserverN needs to talk to ws*, it should pick a node at
>> random (poor man's load balancing).  If that node is down, it needs to
>> fail over to another node, without the calling code knowing or caring
>> what happened.
>>
>> Is there a reliable existing pattern or example out there somewhere,
>> or -- better yet -- something in HttpCore or HttpClient that provides
>> this type of pooling with failover strategy out of the box?  I would
>> rather steal or adapt good code than reinvent this wheel...
>>
>> Any tips?
>>
>> Thanks,
>> Dan
>>
>
> Dan
>
> HttpClient 4.1 supports fail-over based on multiple DNS entries (so
> called multihoming) out of the box. This is actually the reason
> MultihomePlainSocketFactory got deprecated.
>
> Does your application need to support fail-over to a standby node only,
> or you actually need to be able to 'spray' the traffic across multiple
> nodes?
>
> Oleg
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: httpclient-users-unsubscribe@hc.apache.org
> For additional commands, e-mail: httpclient-users-help@hc.apache.org
>
>

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


Re: looking for reliable failover pattern

Posted by Oleg Kalnichevski <ol...@apache.org>.
On Thu, 2011-05-26 at 20:17 -0400, Dan Checkoway wrote:
> Hello,
> 
> I'm looking for recommendations on best practice for client side
> failover...with pooling/keepalive.  I've been rolling my own, but I'm
> migrating to HC and could use some advice.  Here's what I'm faced with
> requirements-wise:
> 
> 1. My app is running on appserver01...n, and it's using HttpClient to
> talk to a web service that's running on ws01...n.
> 
> 2. Unfortunately, my hands are tied and I can't throw a VIP/LB in
> front of ws01...n (wouldn't that just be too easy), and I can't use
> round-robin DNS either (I found MultihomePlainSocketFactory, but it's
> deprecated anyway).  I need to address the ws* boxes individually.
> 
> 3. A key requirement is that I take advantage of persistent HTTP
> connections (keepalive).
> 
> 4. When appserverN needs to talk to ws*, it should pick a node at
> random (poor man's load balancing).  If that node is down, it needs to
> fail over to another node, without the calling code knowing or caring
> what happened.
> 
> Is there a reliable existing pattern or example out there somewhere,
> or -- better yet -- something in HttpCore or HttpClient that provides
> this type of pooling with failover strategy out of the box?  I would
> rather steal or adapt good code than reinvent this wheel...
> 
> Any tips?
> 
> Thanks,
> Dan
> 

Dan

HttpClient 4.1 supports fail-over based on multiple DNS entries (so
called multihoming) out of the box. This is actually the reason
MultihomePlainSocketFactory got deprecated. 

Does your application need to support fail-over to a standby node only,
or you actually need to be able to 'spray' the traffic across multiple
nodes?

Oleg




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