Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize load balancing in SpringCloud-Ribbon

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article is about how to achieve load balancing in SpringCloud-Ribbon. The editor thinks it is very practical, so I share it with you. I hope you can get something after reading this article. Let's follow the editor to have a look.

Ribbon as a client load balancing framework, the default load strategy is polling, but also provides many other strategies that allow users to choose according to their own business needs.

The overall policy code implementation class is shown in figure 1.

The figure shows as follows:

1) BestAvailabl

Select a minimum concurrent request Server, examine the Server one by one, skip if the Server is marked as an error, and then select the smallest Server in the ActiveRequestCount.

2) AvailabilityFilteringRule

Filter out the back-end Server that has been failed and marked as circuit tripped, and filter out the highly concurrent back-end Server or use an AvailabilityPredicate to include the logic to filter the Server. In fact, it is to check the running status of each Server recorded in Status.

3) ZoneAvoidanceRule

Use ZoneAvoidancePredicate and AvailabilityPredicate to determine whether to select a Server, the former to determine whether the performance of a Zone is available, eliminate unavailable Zone (all Server), and AvailabilityPredicate is used to filter out Server with too many connections.

4) RandomRule

Randomly select a Server.

5) RoundRobinRule

Poll for selection, poll index, and select the Server at the corresponding location of index.

6) RetryRule

Retry the mechanism on the selected load balancer policy, that is, if Server is not selected within a configuration period when a policy is selected for request load, you will always try to use subRule to select an available Server.

7) ResponseTimeWeightedRule

The same function as WeightedResponseTimeRule,ResponseTime-Weighted Rule was later renamed to WeightedResponseTimeRule.

8) WeightedResponseTimeRule

Assign a Weight (weight) according to the response time. The longer the response time is, the smaller the Weight is, and the less likely it is to be selected.

This is how SpringCloud-Ribbon achieves load balancing. The editor believes that there are some knowledge points that we may see or use in our daily work. I hope you can learn more from this article. For more details, please follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report