0

As I understand the default load balancer using in Zuul proxy server as DynamicServerListLoadBalancer and it use ZoneAffinityServerListFilter rule to choose server. However, is there any way I can customize the loadbalancer used in zuul proxy server

I have tried to add following configuration to change to loadbalancer Rule:

eureka.client.NFLoadBalancerRuleClassName=com.netflix.loadbalancer.RoundRobinRule

But seems it still stick with default configuration.

Any advice is highly appreciated.

rjdkolb
  • 10,377
  • 11
  • 69
  • 89
Joey Trang
  • 1,105
  • 2
  • 23
  • 44

1 Answers1

4

To change load balancing rule with configuration, you should define ribbon configuration like below.

your_ribbonclient_name.ribbon.NFLoadBalancerRuleClassName=com.netflix.loadbalancer.RoundRobinRule

your_ribbonclient_name shoud be replaced with the proper one for your configuration. In Zuul, ribbon client name is same with service id for each route.

You can also provide your own IRule bean for load balancing rule with @RibbonClient like the following.

@RibbonClient(name = "your_ribbonclient_name", configuration = YourConfigurationClass.class)

You can find an example code here

If you want to apply your Ribbon config to whole ribbon clients in your server, you can do that with @RibbonClients (not @RibbonClient).

@RibbonClients(defaultConfiguration = DefaultRibbonConfig.class)

You can find the example code here, and the related issues is here.

yongsung.yoon
  • 5,489
  • 28
  • 32
  • thanks for your advice. as we are using Zuul for dynamically routing to back-end services, and zuul using DiscoveryClient to get InstanceInfo registed in Eureka so we do not want to configure for each every single services. What we are looking for is that some sort of common configuration for Ribbon at Zuul server for all ribbon call. @yongsung.yoon – Joey Trang Jun 08 '17 at 03:13
  • @Van I've updated the reply. There is a way to apply ribbon config to whole ribbon clients in your server. Probably it will work also for zuul. – yongsung.yoon Jun 08 '17 at 03:53