springcloud之Ribbon
springcloud之Ribbon
Ribbon primarily provides client-side load balancing algorithms.
Other features:
- Service Discovery Integration – Ribbon load balancers provide service discovery in dynamic environments like a cloud. Integration with Eureka and Netflix service discovery component is included in the ribbon library
- Fault Tolerance – the Ribbon API can dynamically determine whether the servers are up and running in a live environment and can detect those servers that are down
- Configurable load-balancing rules – Ribbon supports RoundRobinRule, AvailabilityFilteringRule, WeightedResponseTimeRule out of the box and also supports defining custom rules
Dependency: spring-cloud-starter-netflix-ribbon
load balance strategy:

Configuration
- rule - load balancing rule
- ping - mechanism we use to determine the server's availability in real-time
- ServerList - can be dynamic or static. I
public class RibbonConfiguration { |
spring: |
Notes: Disabled Eureka service discovery component, by setting eureka: enabled to falseDefined the list of servers available for load balancing, in this case, 2 servers
code
|
annotated the RestTemplate with @LoadBalanced which suggests that we want this to be load balanced and in this case with Ribbon.
Failure Resiliencey
Ribbon API can determine the server's availability through the constant pinging of servers at regular intervals and has a capability of skipping the servers which are not live.
How to disable circuit breaker: niws.loadbalancer.availabilityFilteringRule.filterCircuitTripped to false.
https://www.baeldung.com/spring-cloud-rest-client-with-netflix-ribbon