Search code examples
javaspringload-balancingspring-cloud-netflixnetflix-ribbon

How to set ServerListRefreshInterval in ribbon load balancer?


I'm using Spring, Eureka and Ribbon. I want to change the refresh interval for ribbon. While reading the documentation, I found out that I should set the following property:

my-service.ribbon.ServerListRefreshInterval=99999

However, it doesn't help because when I create a load balancer, Spring uses the following constructor

   public DynamicServerListLoadBalancer(IClientConfig clientConfig, IRule rule, IPing ping, 
        ServerList<T> serverList, ServerListFilter<T> filter) {
    this(
            clientConfig,
            rule,
            ping,
            serverList,
            filter,
            new PollingServerListUpdater()
    );

And this constructor doesn't use my property.


Solution

  • I had a look at this topic : How to override the ribbon.serverListRefreshInterval default value in Spring Cloud Ribbon?

    The problem is related to this bug : ribbon.ServerListRefreshInterval ignored #1304.

    The bug has been solved in spring-cloud-netflix 1.3.0.RC1 on March 2017 .

    You are using Spring Cloud Camden.SR7 which uses Spring Cloud Netflix 1.2.7.RELEASE, where the bug wasn't fixed yet.

    Either force the use of spring-cloud-netflix 1.3.0 or above, or switch to a Spring Cloud version that contains this kind of dependency, e.g Spring Cloud Edgware.SR2 (Maven repo) which uses Spring Cloud Netflix 1.4.3.RELEASE