Spring cloud of Ribbon acquaintance

        Ribbon is Netflix released open source project, the main function is to provide the client software load balancing algorithm, an intermediate layer connecting the Netflix service together. Ribbon client components, such as a series of perfect CI connection timeout, retry the like. Simply put, is to list all the machines behind the Load Balancer in the configuration file, Ribbon will help you automatically based on certain rules (such as a simple polling, then connections, etc.) to connect these machines. We can easily use load balancing algorithm Ribbon customizable.

        LB current mainstream program can be divided into two categories: one is centralized LB, LB that the use of a separate facility between consumer and provider services (either hardware, such as F5, can be software, such as nginx), the facility is responsible for the access request is forwarded to the service provider through a strategy; the other is in the process LB, LB logic integrated into the consumer side, consumer service registry learn from what address is available, and then again from their own these addresses are selected by a suitable server. Ribbon belongs to the latter, it is just a class library, integrated consumer process, consumer to get the address of the service provider through it.

The main components of the workflow:

       ServerList: used to obtain the address list. It can be static (providing a fixed set of address), it can also be dynamic (from the registry regularly check the address list).

  ServerListFilter: Use only when dynamic ServerList, for the use of certain tactics filter out part of the address in the original list of services.

  IRule: Select a service address as LB final result. Polling selection strategy, weighted according to the response time of the circuit breaker (Hystrix when available) and the like.

  Ribbon choice at work will be to get a list of all the services available through ServerList, then ServerListFilter filter out part of the address, and finally the rest of the address by a server IRule selected as the final result.

Load balancing strategy:

Built-in load balancing rule class Rule Description
RoundRobinRule Simple polling service list to select the server. It is the Ribbon default load balancing rules.
AvailabilityFilteringRule

Be ignored for the following two servers:

(1) By default, this server if the connection fails three times, this server will be set to "short-circuit" state. The short-circuit state for 30 seconds, if the connection fails again, the duration of the short circuit will increase exponentially ground.

Note: You can modify the configuration loadbalancer <clientName> .connectionFailureCountThreshold short-circuit state is set after the number of times to modify the connection fails. The default is 3 times.

(2) the number of concurrent high server. If a high number of concurrent connections to the server, configure the client AvailabilityFilteringRule rules will be ignored. The line number of concurrent connections may be. <ClientConfigNameSpace> .ActiveConnectionsLimit attributes by the client <clientName> configuration.

 

 

WeightedResponseTimeRule

Given a weight value for each server. The longer server response time, the less weight to the server. This rule will randomly select a server, the weight value will influence the choice of the server.

ZoneAvoidanceRule Area available to the server based on the server selection. Zone classification using the server, the Zone can be understood as a computer room, a rack so on.
BestAvailableRule Which ignores short-circuit the server, and select a lower number of concurrent server.
RandomRule Randomly selecting an available server.
Retry Selection logic to retry mechanism

 

 

Guess you like

Origin blog.csdn.net/syilt/article/details/93376340
Recommended