Load balancing target endpoints without the creation of target servers

Hi,

I have dynamically configured the target endpoints to route to different hosts in different environments using javascript callout .

Is it possible to load balance these target servers without using the traditional approach of static configuration ? I want to load balance them dynamically .

I would like to load balance target servers without creating target servers externally as below.

<TargetEndpoint name="default">
    <HTTPTargetConnection>
        <LoadBalancer>
            <Server name="target1" />
        </LoadBalancer>
  </HTTPTargetConnection>
</TargetEndpoint>

Thanks

0 2 629
2 REPLIES 2

In short the target server is the out-of-box way of load balancing.

Can javascript be used to make the decision to identify a target and use route rules to pick target endpoint. So each target endpoint can represent a target server group that can participate in load balancing.

The decision can be captured in a flow variable called chosenTarget, so the routerules can look like the following. If this does not address your requirement, can you elaborate your requirement.

    <RouteRule name="server1">
        <TargetEndpoint>server1</TargetEndpoint>
        <Condition>(chosenTarget = "server1")</Condition>
    </RouteRule>
    <RouteRule name="server2">
        <TargetEndpoint>server2</TargetEndpoint>
        <Condition>(chosenTarget = "server2")</Condition>
    </RouteRule>

The above snippet makes use of static configuration of target servers. But I have a configuration present in the javascript callout and I use 'target.url' to dynamically route to different targets.

Now, I need to load balance between those target servers. Here, I am not configuring target servers anywhere since all of them are within the javascript callout.

So I need to load balance the below target servers. Is there a way to do it without using the out of the box approach ?

Existing javascript callout that dynamically routesto target servers

var targetCandidates = [
      'http://api.lo5.at/info',
      'http://dc-echo.herokuapp.com/hello',
      'https://echo.getpostman.com/digest-auth'
    ];

/*need to load balance between the target servers */

context.setVariable('target.url', targetCandidates[chosen]);


Thanks