当前位置:网站首页>Microservice avalanche problems and Solutions

Microservice avalanche problems and Solutions

2022-07-23 18:02:00 Liu Chu, Ge Nian

Avalanche problem

Avalanche problem

In microservice , The relationship between services is complicated , A microservice often depends on multiple other microservices .

1533829099748

Pictured , If the service provider I Something went wrong , Part of the business of the current application depends on services I, Therefore, it will also be blocked . here , Others do not depend on services I Our business seems unaffected .

1533829198240

however , dependent service I Your service request is blocked , The user will not get a response , be tomcat This thread will not release , As a result, more and more user requests come , More and more threads will block :

1533829307389

The server supports a limited number of threads and concurrency , Requests keep blocking , Will cause the server to run out of resources , As a result, all other services are unavailable , Then the current service is unavailable .

that , Other services that depend on the current service over time , It will eventually become unavailable , Cascading failed , An avalanche happened :

image-20210715172710340

Solution

There are four common ways to solve the avalanche problem :

1. timeout handler

timeout handler : Set the timeout , If the request exceeds a certain time and there is no response, an error message is returned , Will not wait endlessly

image-20210715172820438

2. Bin wall mode

programme 2: Bin wall mode

The silo wall model comes from the design of the cabin :

image-20210715172946352

The cabin will be separated into multiple independent spaces by partitions , When the hull is damaged , It will only cause part of the space to enter , Control the fault within a certain range , Avoid flooding the whole hull .

It's similar to , The warehouse wall mode can limit the number of threads that can be used by each business , Avoid exhausting the whole tomcat Resources for , Therefore, it is also called thread isolation .

image-20210715173215243

3. Circuit breaker

Breaker mode : from Circuit breaker Statistics the abnormal proportion of business execution , If the threshold is exceeded, it will Fuse The business , Intercept all requests to access the service .

The circuit breaker counts the number of requests to access a service , Abnormal proportion :

image-20210715173327075

When found accessing the service D When the proportion of abnormal requests is too high , Think service D There is a risk of avalanches , Will block access to the service D All your requests , Form a fuse :

image-20210715173428073

4. Current limiting

flow control : Restrictions on business access QPS( Number of requests per second ), Avoid service failure due to sudden increase of traffic .

image-20210715173555158

summary

What is the avalanche problem ?

  • Micro services call each other , Because a service in the call chain failed , Cause the whole link to be inaccessible .

It can be said that :

Current limiting Is the protection of services , Avoid service failure caused by instantaneous high concurrent traffic , To avoid avalanches . It's a kind of The prevention of measures .

timeout handler 、 Thread isolation 、 Degraded fuse When some services fail , Control the fault within a certain range , Avoid avalanches . It's a kind of Remedy measures .

原网站

版权声明
本文为[Liu Chu, Ge Nian]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/204/202207231533391905.html