Can isFallback be used with HealthMonitor configuration in TargetEndpoint?

Not applicable
<TargetEndpointname="default">
  <HTTPTargetConnection>
    <LoadBalancer>
      <Algorithm>RoundRobin</Algorithm>
      <Server name="target1"/>
      <Server name="target2">
        <IsFallback>true</IsFallback>
      </Server>
    </LoadBalancer>
    <Path>/test</Path>
  </HTTPTargetConnection>
</TargetEndpoint>

In the above configuration, if target1 goes down, target 2 is used. But what happens when target1 is back up? Does it add it back to the pool or do we need to use HealthMonitor to add it back to the pool?

Can HealthMonitor be used with isFallback? The docs say that it can be used with MaxFailures. But MaxFailures is not configured for isFallback. Would HealthMonitor still work with isFallback without MaxFailures?

0 7 552
7 REPLIES 7

If you have a HealthMonitor, then, when target1 is back up, it gets added back to the rotation.

If you do not configure a HealthMonitor, then the server never goes back into rotation. From the documentation:

If you configure MaxFailures > 0 without also configuring a HealthMonitor, the TargetServer will be removed from rotation when the target fails the number of times you indicate. Edge does not automatically put the TargetServer back in rotation even after the target is up and running again. To have Edge put the TargetServer back in rotation, redeploy the API proxy and contact Apigee Support to restart the message processors.

isFallback cannot be used with HealthMonitor. That wouldn't make sense. The fallback is intended to return a 503 or other response when none of the "real" backends are healthy.

Hello @Dino,

We have HealthMonitor configured to check the health of target servers. Would the HealthMonitor take care of adding the target server back to rotation once it is up? Or should we do anything manually to add it back to rotation.

Hi - and thanks for the question. Can you please ask this as a new question using the "ask a question" button? And I'll answer there.

5009-ask-a-question.png

@Sathish Balasubramaniyan, @Dino

Short answer, yes but with caveat.

Here's what I've found during a recent test, just happened to need this for another project.

  1. IsFallback works, targets DO get taken out of rotation and fallback target DOES gets used
  2. When a RoundRobin target comes back on line its added immediately and fallback is not used
  3. A HealthMonitor is required for the target server to be taken out of rotation
  4. MaxFailures > 0 with no HealthMonitor does NOT take the target out of rotation

In my test case:

First proxy representing the targets (see target.zip) deployed to different orgs/envs so host is different.

Three target servers configured to the host for each of the target proxies (see management API below to use SSL)

Second proxy configured with HTTPTargetConnection shown below (see targettest.zip)

With this setup I can easily simulate taking the targets out (undeploy the proxy) and observe the responses from the "targettest" proxy. I used a ping response with the proxy host name to see where the response came from (GET /targettest/ping).

With everything running you will see responses from the targettest proxy, switching back and forth between target1 and target2.

When you undeploy target1 and target2 proxies, the fallback target gets used.

NOTE: Here's the caveat (maybe bug), the targettest proxy must be idle for the time period equal to (MaxFailures X IntervalInSec), 25 seconds in the example, in order for the target to be taken out of rotation. If you keep hitting the targettest proxy you will see error response from the undeployed target proxy since its still in rotation. Once MaxFailures count is reached from the healthcheck call without any other responses from the target, it gets taken out of rotation.

I created an HTTPHealthMonitor as shown below:

<HTTPTargetConnection>
    <LoadBalancer>
        <Algorithm>RoundRobin</Algorithm>
        <Server name="target1"/>
        <Server name="target2"/>
        <Server name="target3">
            <IsFallback>true</IsFallback>
        </Server>
        <MaxFailures>5</MaxFailures>
    </LoadBalancer>
    <Path>/target</Path>
    <HealthMonitor>
        <IsEnabled>true</IsEnabled>
        <IntervalInSec>5</IntervalInSec>
        <HTTPMonitor>
            <Request>
                <ConnectTimeoutInSec>10</ConnectTimeoutInSec>
                <SocketReadTimeoutInSec>30</SocketReadTimeoutInSec>
                <Port>443</Port>
                <Verb>GET</Verb>
                <Path>/target/healthcheck</Path>
            </Request>
            <SuccessResponse>
                <ResponseCode>200</ResponseCode>
                <Header name="ImOK">YourOK</Header>
            </SuccessResponse>
        </HTTPMonitor>
    </HealthMonitor>
</HTTPTargetConnection>

To create the target servers using the management API use:

POST {{MGMTSVR}}/v1/o/{{ORG}}/e/{{ENV}}/targetservers/target1

<TargetServer name="target1">
  <Host>yourorgnamehere-test.apigee.net</Host>
  <Port>443</Port>
  <IsEnabled>true</IsEnabled>
  <SSLInfo> 
      <Enabled>true</Enabled> 
  </SSLInfo> 
</TargetServer> 

Attached are the proxies to test this yourself.

target-rev1-2017-05-11.zip

Updated targettest to show error in fault flow, when target proxy is undeployed.

targettest-rev3-2017-05-16.zip

To avoid the "caveat" noted above, set MaxFailures=1, then the server will be taken out of rotation on the first error.

I need to configure 2 target server. A primary server and a secondary server which should be used only when <IsFallback>true</IsFallback>. I have added a HealthMonitor to check the health of server. When primary server goes down, it calls the secondary target server. But when primary server comes back up again, it still going to secondary server. Can someone please post how to set uo loadbalancer with monitor