Search code examples
spring-cloudnetflix-ribbon

Netflix Ribbon (via Spring Cloud) - How to mark a node down forced?


Would it be possible to mark a node down using Ribbon client side load balancing via Spring Cloud?

I have looked into Configuration option to see if there are any inerface methods to mark a node down.


Solution

  • There are a number of ways to do it in Ribbon. See https://github.com/Netflix/ribbon/wiki/Working-with-load-balancers#components-of-load-balancer

    The IPing interface determines liveliness of a node or the ServerListFilter interface filters servers from ServerList.

    To add a custom IPing implementation (reference) for myservice.

    @Configuration
    @RibbonClient(name = "myservice", configuration = CustomConfiguration.class)
    public class MyAppConfiguration {
    }
    

    CustomConfiguration

    protected static class CustomConfiguration {
    
        @Bean
        public IPing ribbonPing() {
            return new CustomPingImpl();
        }
    }
    

    See here for a default for all services.