Hi Guys,
We have a scenario where we have to do a load balancing with two target endpoints based on the availability of the target server. We are using health check HealthMonitor to check whether the target servers are accessible or not.
The challenge here is, we have to append a different query param for “target1” and “target2” servers.
Example:
If target server 1 is reachable (as a result of Health Monitor and Max Failure), then the service should call “target server 1 + query param 1” (i.e https://httpbin.org/get?code=abc)
Otherwise, call “target server 2 + query param 2” (i.e https://mocktarget.apigee.net/get?code=xyz)
Target Server 1 = https://httpbin.org/get
Target Server 1 Query param = abc
Target Server 2 = https://mocktarget.apigee.net/get
Target Server 2 Query param = xyz
We have a KVM where we’ve stored the query param details and assigning it to the query param.
query_param
Initially, we don’t have this load balancing scenario. Hence we have only one value and assigned it to the query param directly. But, now we have to append the different query params according to the target server.
The reason for this, Target server has the multi region capability. Hence we have to achieve the automatic failover in case one region is not available. Since it’s two different regions the query param is also different for both the regions.
<TargetEndpoint name="default">
<HTTPTargetConnection>
<LoadBalancer>
<Server name="target1" />
<Server name="target2" />
<MaxFailures>5</MaxFailures>
</LoadBalancer>
<Path>/get</Path>
<HealthMonitor>
<IsEnabled>true</IsEnabled>
<IntervalInSec>5</IntervalInSec>
<TCPMonitor>
<ConnectTimeoutInSec>10</ConnectTimeoutInSec>
</TCPMonitor>
</HealthMonitor>
</HTTPTargetConnection>
</TargetEndpoint>