Micro Gateway Dynamic Load Balancing to TargetServers

Not applicable

I am trying to understand how I can load balance between target endpoints within a Micro Gateway plugin. The plugin is querying service discovery for endpoints, and when I get the list back i need to be able to set that to route to 1 of the different endpoints.

The plugin is setting these now: req.targetHostname and req.targetPort. Is there a way to save multiple servers to Host and have apigee balance that, or maybe there is a load balancing variable that can be set?

0 5 685
5 REPLIES 5

@Srinandan Sridhar may be able to answer?

Former Community Member
Not applicable

My perference is you use an external service discovery tool for this. I was thinking some like Consul or Eureka.

There is a sample Eureka implementation here: https://github.com/apigee/Microgateway-plugins

What you have done will also work.

I am using an external service discovery tool to find all of my services, and i am getting a list back from that tool. The problem i am having is when the number of service endpoints changes. If i query my tool for "service-a" and it gives me 2 nodes back how can my plugin have Apigee balance between them. Also if on my next query i get 4 nodes back, I do not know how to specify that in plugin format. Are there any load balancing variables that I should be setting instead of req.targetHostname?

Former Community Member
Not applicable

I understand your question. No, there are no load balancing features or variables at the moment. You're limited to the logic you can implement in the plugin.

Former Community Member
Not applicable

One more thing, you may want to refer to this discussion also: https://github.com/apigee/microgateway-core/issues/81