Is it possible to use a random selection algorithm for RouteRules across multiple TargetEndpoints?

My requirement is about working with two services and multiple servers. My endpoints will be deployed in multiple servers (could be more than 4) divided in two services.

I must do something like a RoundRobin balancing between those two services and a Weigthed among the servers.

Is this possible?

The URL must be the same, for now.

I thought in two options:

1) Having two proxy endpoints with the same URL, but apparently this is NOT possible. Also I can't find a way to do a RoundRobin here.

2) Having only one proxy endpoint and doing a RoundRobin balancing between the services and, into the Target Endpoints, doing a Weigthed balancing among the servers. I couldn't find a way to do a RoundRobing balancing between the two services

I couldn't find a way to do this, so far. If someone can give me some help I would appreciate it.

This is the schema that I thought.

├── Service 1
│      ├── Server 1 
|      ├── Server 2
|      └── Server 3
└── Service 2
       ├── Server 1 
       └── Server 2
0 3 344
3 REPLIES 3

Hi @Nahuel Garcia

The best way that I can think of is to use RouteRules to route to different services, see here

A similar question was answered by @Mike Dunker on S.O here

And eventually use load balancer to manage traffic to multiple servers, refer here

Cheers,

Manas Dikonda

You cannot configure 2 proxies to listen on the same vhost and basepath.

Therefore your option 2 is the only option.

Apigee includes a roundrobin and weighted load distribution mechanism, with the TargetServer entity.

But of course you could also "roll your own" weighting in RouteRules. This would allow your single proxy endpoint to select a routerule by weighted random distribution, and then within that routeRule, select a target, and within that Target, perform the second level of distribution.

How can you perform weighted selection of routerules? You can use just a little bit of JavaScript.

Maybe see this for a start:

https://github.com/DinoChiesa/ApigeeEdge-BlueGreen-1

Not applicable

I have recently implemented exactly the same as your requirement. I have used javascript to dynamically configure the target.url. I have used a counter from the quota to implement the round-robin algorithm for choosing the backend. And this works pretty well.