当前位置:网站首页>Alibaba cloud microservices (III) sentinel open source flow control fuse degradation component

Alibaba cloud microservices (III) sentinel open source flow control fuse degradation component

2022-07-06 13:08:00 Geometer

In microservice , Stability has always been an unavoidable topic , A lot of times , You will encounter a large amount of traffic suddenly onto the system, which will make the system unable to carry
For example, Taobao's double 11 promotion may appear
1. The instantaneous peak exceeds the maximum load
2. The surge of traffic broke the system
3. Hot goods crowd out normal traffic
4.CPU Load You can't live high

Possible reasons for unreliable service :
1.RPC Overtime
2. The abnormal proportion is increasing
3. The queue is full
4. Thread pool full

Occasionally, a service hangs up in the micro service
If the service is dragged down and makes itself unavailable, it will drag down other services later , And then lead to avalanches
So for these scenarios of micro service stability , Flow degradation is very important to ensure stability , To solve this problem , There are generally the following measures

1. Current limiting , hold QPS Limit to a certain threshold
2. Traffic shaping , Traffic is random and unpredictable , Many times we need to adjust the flow to the desired shape, such as slowly increasing rather than suddenly increasing
3. Fusing the drop , Avoid being overwhelmed by other services

Services are generally divided into consumer and provider:
stay provider The terminal should carry out current limiting protection , Ensure that it is not overwhelmed by the surge of traffic , In order to ensure provider Normal call of , We can
1. Current limiting protection , Too fast calls are directly rejected
2. Authorized protection , Unauthorized applications will be rejected directly
3. System protection ,load Stop service beyond the threshold
4. Hotspot protection , Enhanced current limiting protection
consumer In order to prevent being dragged down by unstable service calls , When the service call exceeds the time threshold or request quantity , Auto fuse
 Insert picture description here

Hystrix The main focus is thread pool isolation , The advantage is that the isolation is relatively complete , The disadvantage is that when there are many service calls , It will create a thread pool according to each service call , The thread pool creates a large number of threads , There will be harm of context switching .ThreadLocal There will be problems in the scene , Such as relying on ThreadLocal Carry out the transmission of things or some flags

About Sentinel Start the console first , After the console is started, access it in the browser sentinel In the console
 Insert picture description here
To configure , Access sentinel
 Insert picture description here
 Insert picture description here
At this time, call the interface
 Insert picture description here
You can see the call result in the browser , Information can be seen on the console
 Insert picture description here
Use the console to limit the current of this interface
 Insert picture description here
 Insert picture description here
Can be found when qps When the set threshold is exceeded , Fuse
 Insert picture description here
 Insert picture description here

Here's how gateway
See this post for related introduction :
https://www.cnblogs.com/xuweiweiwoaini/p/13858898.html
Configure relevant information in the local project
 Insert picture description here
hold demo The beginning and httpbin The initial flow is led into different positions of the channel
Call demo Interface
 Insert picture description here
Can be in foo-service-route see , After several visits, you can find it on the console demo-gateway The application of
 Insert picture description here
Set parameter current limit in the console
 Insert picture description here
 Insert picture description here

原网站

版权声明
本文为[Geometer]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207060914341029.html