Target Server Dynamic update for Disaster Recovery Scenario

Hi All,

I have a requirement for my Disaster recovery scenario. My target server value will change based on the Data Center. Without re-deploying to update the target server, do we have an option to load balance this automatically?

  1. When DC changed from A to B , I would like to have target server as xyz.
  2. When Switched back to A, , I would like to have target server as abc.

Thanks 

 

Solved Solved
1 2 125
1 ACCEPTED SOLUTION

Are you using LoadBalancing in the TargetEndpoint?  
Or is it a simple HTTPTargetConnection with no loadbalancer configured in Apigee ?

If I were doing this I might use a RouteRule in the ProxyEndpoint, with a Condition like this: 

 

  <RouteRule> 
    <Condition>datacenter = "east"</Condition>
    <TargetEndpoint>EastPreferred</TargetEndpoint>
  </RouteRule>

  <RouteRule> 
    <!-- fallback -->
    <TargetEndpoint>WestPreferred</TargetEndpoint>
  </RouteRule>

 

And then have two distinct TargetEndpoints, both of which use LoadBalancing.  The EastPreferred will prefer abc, and fallback to the xyz server.  While the WestPreferred will prefer xyz, and fallback to the abc server. 

 

<TargetEndpoint name="EastPreferred">
    <Description/>
    <FaultRules/>
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <Flows/>

    <HTTPTargetConnection>
      <Properties>
        ...
      </Properties>

      <LoadBalancer>
        <Algorithm>RoundRobin</Algorithm>
        <Server name="east"/>
        <Server name="west">
          <IsFallback>true</IsFallback>
        </Server>
        <MaxFailures>2</MaxFailures>
      </LoadBalancer>
      <Path>/whatever</Path>

 

And then you do ... the converse in the WestPreferred targetendpoint. 

To use this you have to create a TargetServer definition in your environment

This approach requires that the API proxy can determine, at runtime, in which datacenter it is running. You can use the system.region.name variable to help. In my Apigee X installation I get 

As a value there.  But if you are using something other than apigee X, then your values will be different I guess.

 

View solution in original post

2 REPLIES 2

Are you using LoadBalancing in the TargetEndpoint?  
Or is it a simple HTTPTargetConnection with no loadbalancer configured in Apigee ?

If I were doing this I might use a RouteRule in the ProxyEndpoint, with a Condition like this: 

 

  <RouteRule> 
    <Condition>datacenter = "east"</Condition>
    <TargetEndpoint>EastPreferred</TargetEndpoint>
  </RouteRule>

  <RouteRule> 
    <!-- fallback -->
    <TargetEndpoint>WestPreferred</TargetEndpoint>
  </RouteRule>

 

And then have two distinct TargetEndpoints, both of which use LoadBalancing.  The EastPreferred will prefer abc, and fallback to the xyz server.  While the WestPreferred will prefer xyz, and fallback to the abc server. 

 

<TargetEndpoint name="EastPreferred">
    <Description/>
    <FaultRules/>
    <PreFlow name="PreFlow">
        <Request/>
        <Response/>
    </PreFlow>
    <PostFlow name="PostFlow">
        <Request/>
        <Response/>
    </PostFlow>
    <Flows/>

    <HTTPTargetConnection>
      <Properties>
        ...
      </Properties>

      <LoadBalancer>
        <Algorithm>RoundRobin</Algorithm>
        <Server name="east"/>
        <Server name="west">
          <IsFallback>true</IsFallback>
        </Server>
        <MaxFailures>2</MaxFailures>
      </LoadBalancer>
      <Path>/whatever</Path>

 

And then you do ... the converse in the WestPreferred targetendpoint. 

To use this you have to create a TargetServer definition in your environment

This approach requires that the API proxy can determine, at runtime, in which datacenter it is running. You can use the system.region.name variable to help. In my Apigee X installation I get 

As a value there.  But if you are using something other than apigee X, then your values will be different I guess.

 

Thank you for your response. I have used the below which is working fine. But is there anyway I can avoid failure in this case, 

<LoadBalancer>
        <Algorithm>RoundRobin</Algorithm>
        <Server name="east"/>
        <Server name="west">
          <IsFallback>true</IsFallback>
        </Server>
        <MaxFailures>2</MaxFailures>
      </LoadBalancer>
      <Path>/whatever</Path>

 It fails for 2 times and then it starts routing the calls to Fall back Server. I am trying to see if I can avoid that 2 fails.

 

thanks