Micropower service learning (six) - micro-management services

Micro service management background, consumer service A service provider needs to address B inquiry by the registry, and then initiate calls may be sent to the following:

  Registration center downtime

  B by the service provider node goes down

  A network between the service consumer and the registry barrier

  Network between the service provider and the registration center barrier B

  A network between service consumers and service providers barrier B

  Some service providers Node B slow performance

  B service provider problems in a short time

In this regard, we need the appropriate service management tool.

  

  Node Manager

  Service call fails, usually caused by two types of reasons, like when a service provider's own problems, such as server downtime, process unexpectedly quits etc; a class of network issues, such as service providers, registration centers, three service consumer network problem between any two persons appear. There are two main node management tools:

  1, the registry initiative removal mechanism

  Requires the service provider reports regularly to the registry heartbeat, registry node last reported heartbeat of time depending on the service provider and the reporting heartbeat time comparing once beyond a certain time, it is considered a service provider problem, then the node from removal of the list of services, and the most recent list of available services pushed to service consumers.

  2, the service consumer removal mechanism

  Although the registry initiative removal mechanism can solve the service provider node unusual problem, but if it is because of abnormal network between the registry and the service provider appears, the worst case is a registered center will service all nodes removed, resulting in consumption of services who no available service node calls, but in fact, this time the service provider itself is normal. So, we will survive detection mechanisms used in this end of the service consumer more reasonable, if the service consumer calls the service provider node fails, the node will be removed from memory stored in the provider node list of available services.

 

  Load Balancing

  In general, the service provider node is not the only, way more than is present in the cluster. Due to different batches of machine purchase, configure the different services of the node itself also can vary widely, newly purchased machine CPU and memory configuration may be higher, the same request, the performance is better than the old machine. For service consumers, when selecting a node from the list of services available, if we make higher allocation of new machine carries some traffic more than words, we will be able to take full advantage of the performance of the new machine.

  Common load balancing algorithms mainly include the following.

  1, random algorithm

  A node randomly selected from the available serving nodes.

  2, according to a fixed weight of available service node polls all right if the service node weights are the same, the amount of calls each node is the same. But right node can be configured to retune some bigger hardware.

  3, the least active call algorithm

  The algorithm in this section of the service consumer memory dynamically maintains the same number of connections between each service node, when calling a service node, give the number of connections between the service node plus 1, the call returns after , gave 1 minus the number of connections. Then each time the selected service node, depending on memory in reverse order to maintain the connection, select the smallest number of nodes connected to initiate calls, that is, choose the smallest amount of calls the service node, when the best theoretical performance.

  4, consistency Hash algorithm

  Refer to the same parameters of the request is always sent to the same service node. When a service node fails, the original request sent to the node, node-based virtual mechanism, in equal shares to the node, will not cause dramatic changes.

 

  Routing Service

  For service consumers, which node list of available services in memory of choice not only, also decided by the load balancing algorithm decided by the routing rules.

  Routing rules: rule by certain conditions, such as an expression or a regular expression to define the scope of service nodes.

  Why make routing rules? By the following two reasons

  1, there is gray business publishing needs

  Service provider to do a function change, some people just want to use.

  2, multi-room nearest access requirements

  Access between different due to cross IDC IDC, some high timeliness business, should try to be in the same internal IDC. Generally you can control access by IP segment rules.

 

  Fault-tolerant service

  Background: In the case of a service call fails, it is necessary to restore automatic means to ensure the call is successful. Common methods are as follows:

  FailOver: failure automatic switching. After the service consumers find or call fail timeout, automatically selects the next node from the list of services available in relaunching the call, you can also set the number of retries. It requires service call operations must be idempotent.

  FailBack: failure by. After the service the consumer is the call fails or times out, not retry, but according to the details of the failure to determine the follow-up implementation strategy.

  FailCache: Failed cache. After the service the consumer is the call fails or times out, not retry initiated immediately.

  FailFast: Quick failed. After the service the consumer is to call a failure, not try again.

  

  

Guess you like

Origin www.cnblogs.com/gzhcsu/p/11413432.html