Spring Cloud LoadBalancer vs Ribbon: Key Differences and Why Ribbon Was Replaced
The article explains the functional and architectural differences between Spring Cloud LoadBalancer and Netflix Ribbon, why Ribbon entered maintenance mode and was replaced, outlines migration steps, compares configuration, caching, reactive support, and provides code examples and common interview questions for Java developers.
Interview Focus
Framework evolution awareness : Interviewers want to see if you understand the version evolution of Spring Cloud and the migration from Netflix OSS to Spring Cloud self‑developed components.
Load‑balancing fundamentals : Depth of understanding of service discovery, instance selection, and health‑check mechanisms.
Technology selection awareness : Ability to explain why the official roadmap moved from Ribbon to LoadBalancer, reflecting judgment on component lifecycle and maintenance strategy.
Core Answer
Ribbon is Netflix’s open‑source client‑side load‑balancing component, while Spring Cloud LoadBalancer is the Spring‑official replacement. The fundamental reason for replacement is that Ribbon has entered Maintenance Mode and is no longer actively updated.
Key Differences
Maintainer : Ribbon – Netflix (no longer updated); LoadBalancer – Spring official (continuous).
Status : Ribbon – maintenance mode, no new features; LoadBalancer – actively developed.
Ecosystem : Ribbon – part of Netflix OSS; LoadBalancer – Spring Cloud self‑developed.
Cache mechanism : Ribbon includes its own Spring cache via SpringClientFactory; LoadBalancer relies on Spring Cache (e.g., Caffeine).
Configuration : Ribbon uses fine‑grained .properties / .yml files; LoadBalancer config is based on LoadBalancerClient.
Dependency size : Ribbon is relatively heavy with many transitive dependencies; LoadBalancer is lightweight with a small core package.
Reactive support : Ribbon does not support Reactive; LoadBalancer natively supports Reactive (WebClient).
Default integration : Ribbon was default before Spring Cloud 2020.x; LoadBalancer becomes default from Spring Cloud 2020.x onward.
Deep Analysis – Why Ribbon Was Retired
Ribbon was replaced not because it was unusable, but because the entire Netflix OSS line entered maintenance mode, causing a chain reaction.
~2015: Netflix stack (Eureka + Ribbon + Hystrix + Zuul) became the de‑facto standard for microservices.
2018‑2019: Netflix announced core components would be in maintenance mode, halting new feature development.
2020: Spring Cloud 2020.x (code‑named Ilford) removed Netflix dependencies and introduced self‑developed alternatives, including LoadBalancer.
Core logic: Spring cannot depend on a third‑party library that no longer receives updates, so it built its own replacement.
Architecture Comparison
Ribbon adopts its own interface set ( ServerList, IRule, IPing) tightly coupled with Netflix OSS. LoadBalancer uses Spring‑style interfaces ( ServiceInstanceListSupplier, ReactiveLoadBalancer) for seamless Spring integration and native Reactive support.
Load‑Balancing Strategies
Round‑Robin : Ribbon – RoundRobinRule; LoadBalancer – RoundRobinLoadBalancer (default).
Random : Ribbon – RandomRule; LoadBalancer – RandomLoadBalancer.
Weighted : Ribbon – WeightedResponseTimeRule; LoadBalancer – requires custom implementation or integration with Nacos weight.
Best‑Available : Ribbon – BestAvailableRule; LoadBalancer – custom implementation needed.
Hash : Neither provides built‑in hash support.
LoadBalancer uses round‑robin by default; other strategies can be switched by defining a custom bean of type LoadBalancerClient.
Code Comparison
Ribbon (old)
// application.yml configuration
// user-service:
// ribbon:
// NFLoadBalancerRuleClassName: com.netflix.loadbalancer.RandomRule
@Configuration
public class RibbonConfig { }
@RestController
public class OrderController {
@Autowired
private RestTemplate restTemplate;
public User getUser(Long userId) {
// Ribbon intercepts request and selects instance
return restTemplate.getForObject("http://user-service/api/users/" + userId, User.class);
}
}LoadBalancer (new)
// Dependency spring-cloud-starter-loadbalancer is auto‑included in Spring Cloud 2020.x+
@Configuration
public class LoadBalancerConfig { }
@RestController
public class OrderController {
@Autowired
private RestTemplate restTemplate;
@Autowired
private WebClient.Builder webClientBuilder;
// Synchronous call (same as Ribbon)
public User getUser(Long userId) {
return restTemplate.getForObject("http://user-service/api/users/" + userId, User.class);
}
// Reactive call (Ribbon cannot do this)
public Mono<User> getUserReactive(Long userId) {
return webClientBuilder.build()
.get()
.uri("http://user-service/api/users/" + userId)
.retrieve()
.bodyToMono(User.class);
}
}Migration cost is low – the @LoadBalanced annotation stays the same, and LoadBalancer adds native WebClient support.
Migration Checklist
Remove spring-cloud-starter-netflix-ribbon from pom.xml to avoid conflicts.
Add a Spring Cache implementation (e.g., Caffeine) if caching is required.
<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
</dependency>For custom strategies, implement ReactorServiceInstanceLoadBalancer and register it as a @Bean.
Configure health checks via the service registry (e.g., Nacos) because LoadBalancer does not provide its own IPing implementation.
High‑Frequency Interview Follow‑Ups
Which load‑balancing strategies does LoadBalancer support and how to customize them? (Default round‑robin and random; custom requires implementing ReactorServiceInstanceLoadBalancer.)
Difference between client‑side and server‑side load balancing? (Client‑side selects instances directly, avoiding an extra hop; server‑side uses a proxy such as Nginx or F5.)
Other Netflix components replaced after Spring Cloud 2020.x? (Ribbon → LoadBalancer, Hystrix → Sentinel/Resilience4J, Zuul → Spring Cloud Gateway; Eureka remains but Nacos is recommended.)
Memory Mnemonic
Ribbon retired, LoadBalancer takes over – remember the three migration steps: remove the Ribbon dependency, add a cache implementation, and adjust the load‑balancing strategy.
Conclusion
Ribbon was retired because the entire Netflix OSS ecosystem entered maintenance mode, forcing Spring to take control of core components. LoadBalancer is lighter, embraces Reactive programming, and integrates seamlessly with the Spring ecosystem, becoming the default client‑side load‑balancer in Spring Cloud 2020.x and later. Migration involves a few straightforward steps, and new projects should adopt LoadBalancer directly.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
Java Architect Handbook
Focused on Java interview questions and practical article sharing, covering algorithms, databases, Spring Boot, microservices, high concurrency, JVM, Docker containers, and ELK-related knowledge. Looking forward to progressing together with you.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
