Need right approach to set Load Balancer for proxy

Asm
Bronze 1
Bronze 1

Hi,

I need to set a load balancer to proxy for distributing traffic across 2 servers but with different backend endpoints 

These endpoints have different input objects for which i have made common front end request & post data transformation sending to respective backends  

Can anyone suggest the right approach as all the documents have configured the load balancers to same endpoints on different servers but i need to configure different paths to respective servers 

  ...
  <HTTPTargetConnection>
    <LoadBalancer>
      <Server name="A1"/>
      <Server name=A2"></Server>
    </LoadBalancer>
  </HTTPTargetConnection> 

Reference :https://cloud.google.com/apigee/docs/api-platform/deploy/load-balancing-across-backend-servers 

0 7 301
7 REPLIES 7

To switch between target endpoints, the best way to achieve it is by defining multiple TargetEndpoints and have a Condition based selection on the TargetEndpoint. Refer to the screenshot below.

ganadurai_0-1669997239262.png

Hope this helps.
Thanks.

 




 

Yes.

Multiple TargetEndpoints will allow you to insert target-specific manipulation of the pending outbound request - change the path, the payload, the headers, etc. 

But using the multiple TargetEndpoint objects implies that you are not using the Apigee load balancer capability. 

Which means .. to use BOTH the load balancer that is builtin to Apigee, as well as target-specific manipulation of the request payload, you need to:

  • user loadbalancer in the first proxy (the one closest to the external network)
  • each server in the LB should point to a distinct API proxy 
  • those distinct API proxies can each have a single TargetEndpoint, pointing to the eventual target, and they can have the  target-specific request manipulation. 

So you would have the load balancer, balancing load across Apigee-hosted proxies, and each of those proxies to a single external target.

Hello,

You rightly understood but on your solution 
                each server in the LB should point to a distinct API proxy 

Endpoint 1: https://{{hostname specified in target server}}/k1/v1/effect
Endpoint 2: https://{{hostname specified in target server}}/utility/effect

Both of the above proxies are distinct & perform same functionality but are pointing to different servers
Now while implementing the load balancer we need to specify the path which is  where i am stuck 
As both of my endpoints are having different paths

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

Thanks

The path-specific stuff goes into the API proxies.  


@Asm wrote:

Endpoint 1: https://{{hostname specified in target server}}/k1/v1/effect
Endpoint 2: https://{{hostname specified in target server}}/utility/effect


What I'm saying is, target1 should point to an API Proxy.  Read that again.  An API Proxy managed in Apigee. 

The API Proxy can point to https://{{hostname specified in target server}}/k1/v1/effect 

The target2 can point to a different API Proxy.  Within that different API proxy you can point to a different path. 

 

Endpoint 1: https://{{hostname specified in TARGET1}}/k1/v1/effect
Endpoint 2: https://{{hostname specified in TARGET2}}/utility/effect

Both of the above endpoints are deployed as a seperate proxy which are working individually
When i am using the load balancer concept in first api proxy "Target Enpoint" to route traffic to second api proxy based on alogorithm with below logic

<HTTPTargetConnection>
<LoadBalancer>
<Algorithm>Weighted</Algorithm>
<Server name="TARGET1"/>
<Server name="TARGET2"/>
</LoadBalancer>
<Path>/k1/v1/effect</Path> // This path gets applied to both the Targets based on alogorithm
</HTTPTargetConnection>

TARGET1 will work fine but when load balancer invokes TARGET2 the endpoint becomes
https://{{hostname specified in TARGET2}}/utility/effect/k1/v1/ which is incorrect

I cannot put a condition in this case to remove the path suffix as its valid for Target 1 but invalid for Target 2

Please let me know if this is possible
Hope I am able to describe my issue

Yes, I understand

If you want different paths for different targets, you will need to use the API proxy in front of the target.  Manipulate the URL path in the proxy.  That's the point of the API Proxy there.  It gives you the chance to change the path. 

In the proxy for target1, do nothing. In the proxy for target2, manipulate the path the way you want it. 

Thanks for the reply

But i wanted to use the load balancer concept of Apigee in my use case

Multiple target endpoint basis of conditional approach is not what i want to achieve as it cannot distribute traffic on any algorithm like load balancers provide