In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article mainly explains "how to understand the flow control protection scenarios and countermeasures of micro-services". Interested friends may wish to take a look. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn "how to understand the flow control protection scenarios and countermeasures of microservices".
1. The service is called by overload
When an interface service of service D is invoked by upstream service overload, if service D is not protected, the whole service D may be dragged down. In this scenario, we need to configure a current limit on service D to protect service D from being overrun as a whole.
Countermeasures: configure traffic protection rules for service provider D to control the traffic entering service D, so as to provide protection to service D. There can be multiple policies when triggering traffic control, such as: quick failure, preheating mode, queuing waiting, preheating mode + queuing waiting.
Quick failure: throw an exception directly when flow control occurs.
Warm-up mode: a mode in which traffic increases slowly when flow control occurs. As shown in the figure below, the traffic QPS increases slowly from 200to 600.
Queuing: requests pass at a uniform speed, and too many requests need to be queued. There is a timeout in the queue, and a traffic control exception is thrown beyond the queuing time. The effect is shown in the following figure: request QPS to maintain a uniform speed of 1000.
Prefetch mode + queue waiting: this mode is the superposition mode of preheating and queuing waiting, and requests are slowly increasing at a uniform speed. As shown in the following figure: the request slowly increases from 0 to 500, and then increases to 1000 after passing at a uniform speed for a period of time.
Second, slow invocation or failure of service
The following scenario An invokes B, An invokes C, and An invokes D. when service B is unstable, service An invokes service B with slow invocation or a large number of exception errors. This scenario, if not intervened, may affect the situation in which A calls C and A calls D.
Countermeasures: an invokes B to configure the circuit breaker degradation rule, when slow invocation or exception occurs in service B instability, if the threshold is triggered, the invocation of service B will be broken, thus protecting the normal conditions of service A calling C and service An invoking D.
Fuse effect: the realization of fuse is usually realized by circuit breaker, the specific process is:
When the slow call ratio, exception ratio and exception number threshold are met, a circuit breaker (OPEN) is triggered and all requests are rejected within the circuit breaker time.
When the fuse has passed the defined duration, the state changes from OPEN to HALF_OPEN.
No slow call or exception occurs in the next request, and the end of the circuit breaker is changed from HALF_OPEN to (CLOSED).
When a slow call or exception occurs in the next request, the circuit breaker continues, and the probe status (HALF_OPEN) changes to (OPEN).
III. Service resources are crowded.
In a distributed link, if a slow call occurs on one link, it will squeeze the other links. In addition to configuring fuse degradation mentioned above, it can be isolated through thread concurrency control.
There are three links in the following figure, of which link 1 has a slow call due to the instability of service E.
A slow call to Link 1 may result in the following:
The increase in the number of link 1 threads squeezes service D resources
Excessive squeeze of service D resources, resulting in instability of links 2 and 3
Extreme circumstances make the entire service D unavailable, causing avalanches in severe cases
Countermeasures: by setting rules on the number of threads of MethodA1 and MethodA2 of service D, blocking will be triggered when the threshold is exceeded, and calls will no longer be made downstream to avoid avalanches caused by unavailability.
Concurrency control effect the number of concurrent threads of the caller is set to 10 in the figure below. As can be seen from the query per minute, the number of threads has been maintained at 10.
Fourth, data overheating crowds out resources
Hot spot data, such as: hot-selling products at the time of great promotion, second-killing products, etc. As shown in the following figure, if the single flow of hot goods is not controlled, it may squeeze other goods and affect the entire order issuing experience.
Countermeasures: by measuring the speed of hot spot parameters, configuring flow control rules, and triggering flow control when the threshold is exceeded. For example, by measuring the speed of the input product ID, when the set threshold is exceeded, the flow control is triggered to avoid excessive crowding of resources.
V. General protection group measures
In the above phenomenon, whether the service is unstable, crowded, or overloaded. In addition to the above protective measures, services can be graded and grouped.
The following figure shows that service An and service D are core services, and service B and service C are non-core services. By grouping Service D, it is divided into group 1 and group 2. Grouping 1 only allows core service invocation, while grouping 2 only allows non-core service invocation.
The advantage of doing this is to physically isolate the traffic, avoid squeezing the core business traffic caused by non-core business traffic, and protect the stability of the core link.
The grouping measure @ 1 can usually change the registry path implementation, service An and service D (group 1) are placed in the same registry path (for example: soa-group1); service B, service C, and service D (group 2) are placed in a different registry path (for example, soa-group2).
The grouping measure @ 2 is realized by marking the service node of the packet, for example, the service D (packet 1) node is marked as group1, and the service D (packet 2) node is marked as group2. When the service consumer subscribes to the node, the node invocation is filtered according to different groups.
At this point, I believe you have a deeper understanding of "how to understand micro-service flow control protection scenarios and countermeasures". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.