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.
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.
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]);