Search code examples
spring-cloudnetflix-eurekaspring-cloud-netflixnetflix-ribbon

Spring Cloud Netflix: What is the difference between ribbon.NIWSServerListClassName and ribbon.listOfServers?


I'm using Ribbon along with Eureka.

My application is able to call the other-service in both the following configurations. I'm using NIWSServerListClassName in first and listOfServers in second.

other-service:
  ribbon:
    eureka:
      enabled: true
    NIWSServerListClassName: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
    ServerListRefreshInterval: 1000

.

other-service:
  ribbon:
    eureka:
      enabled: true
    listOfServers: com.netflix.niws.loadbalancer.DiscoveryEnabledNIWSServerList
    ServerListRefreshInterval: 1000

I've seen both NIWSServerListClassName and listOfServers being used in spring-cloud-netflix GitHub issues (and in some places in docs also) for getting server list for ribbon.

What is the difference between these two ribbon properties? Do they serve the same purpose?


Solution

  • The documentation below explains that listOfServers is for Ribbon, and gets overridden if Eureka is used.

    6.5 Using Ribbon with Eureka

    When Eureka is used in conjunction with Ribbon (that is, both are on the classpath), the ribbonServerList is overridden with an extension of DiscoveryEnabledNIWSServerList, which populates the list of servers from Eureka.

    They go on to say that when Eureka is not used, you may use listOfServers:

    However, if you prefer not to use Eureka, Ribbon and Feign also work..... You can supply the configuration as follows stores:
    ribbon: listOfServers: example.com,google.com

    From: https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-ribbon.html