In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/03 Report--
This article will explain in detail what is the real relationship between circuit breaker and demotion in JAVA. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.
Downgrade
What is a service downgrade? There are mainly the following situations of demotion.
Timeout: when the downstream service responds too slowly for some reason, the downstream service actively stops some less important business, releasing server resources and increasing response speed!
Unavailable: when the downstream service is unavailable for some reason, the upstream actively invokes some local downgrade logic to avoid stutters and quickly return to the user!
Current limit: prevent the service from crashing due to too many upstream service requests, so limit the number of requests to achieve the purpose of protecting downstream services. When the requested traffic reaches a certain threshold, it directly rejects redundant requests and performs degradation logic.
Seeing this, I believe you have seen a common point, that is, when the above three (timeout, unavailable, current limit) trigger, they all follow the same logic, that is, degradation logic, which is called fallback in hystrix.
What is a service breaker?
Fuse is easy to understand. It's a process of disconnection.
A fuse is like a fuse at home, when the current reaches a certain condition, for example, the current of the fuse is 5A, if your current reaches 6A, because the fuse cannot withstand such a high current, the fuse will melt. at this time, the circuit will be disconnected, playing the role of protecting electrical appliances.
The same is true in micro-services, when the downstream service suddenly becomes unavailable or the response is too slow for some reason, the upstream service stops calling the target service and releases resources quickly in order to ensure the availability of its overall service. Resume the call if the target service condition improves
The relationship between circuit breaker and demotion
Having said so much, in fact, we can think of that downgrade and circuit breaker are actually two different processes in service security. When a service fails, it must disconnect (circuit break) the connection with the service first, and then execute the downgrade logic.
Well, since the downgrade logic is implemented anyway, it can be understood that demotion is a design idea, which is an interface at the java level, and a circuit breaker is a different implementation of demotion. Their relationship is shown below:
Demotion mode
So now that we know that demotion is an interface, let's take a look at how they are implemented.
1. Fuse degradation (not available)
The circuit breaker logic is like this, A service calls B service, and after the number of failures reaches a certain threshold, the circuit breaker of A service opens and no longer requests B service, but directly executes the local fallback method. This is called circuit breaker degradation. Seeing here, you may already understand that circuit breaker is only one of the ways to implement the degradation.
2. Time-out demotion
When the same A service invokes B service, when the B service response exceeds the threshold set by A service, the degradation logic will be executed.
3. Current restriction and demotion
It is the same A service that invokes service B, and the connection of service A has exceeded the maximum number of connections it can carry. For example, the number of connections that A can carry is 5, but the current concurrency has six requests at the same time, the first five requests can be requested normally, and the last one will be rejected directly, and the fallback degradation logic will be executed.
This is the end of the article on "what is the real relationship between circuit breaker and demotion in JAVA". I hope the above content can be helpful to you, so that you can learn more knowledge. if you think the article is good, please share it out for more people to see.
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.