5

I am using Spring Cloud with NetflixOSS in my microservice project. Also, I am using Ribbon with Feign Client as my client side load balancer. I was wondering, is there any possibility to implement or choose different types of load balancing algorithms for Ribbon? Because as I understood, the default is round robin.

Thanks in advance!

Nikhil Pareek
  • 734
  • 9
  • 24
branko terzic
  • 654
  • 1
  • 8
  • 27

1 Answers1

7

Yes, it is possible. See the docs for full details how to customize. For a @FeignClient("foo") and a random load-balancing rule you could do:

@Configuration
@RibbonClient(name = "foo", configuration = FooConfiguration.class)
public class TestConfiguration {
}

@Configuration
public class FooConfiguration {
    @Bean
    public IRule ribbonRule(IClientConfig config) {
        IRule rule = new RandomRule();
        rule.initWithNiwsConfig(config);
        return rule;
    }
}

See the ribbon wiki for some more details and here for more implementations.

spencergibb
  • 24,471
  • 6
  • 69
  • 75