Circuit Breaker Pattern I checked

Trigger to investigate

At the drinking party, the young people of the company are Netflix's Hystrix, which is the Circuit Breaker Pattern, which is Netflix and Bee. I was saying, but honestly what is that? Since it was in a state, I would like to keep track of what it is like.

What is it like?

Circuit Breaker is a "breaker" in Japanese. If you turn on the air conditioner with the dryer on, it will fall off.

Normally, if the callee fails to connect due to an API call, I think that it waits until a timeout and returns an error.

It is not preferable because it is wasteful to request and the load on the other party is increased even though it is known that an error will occur.

If you put a breaker in such a place, if the request fails beyond the threshold value, the breaker will be turned off and an error will be returned immediately.

I think that the breaker in the Web service is used to stop the chain of obstacles.

Chain of obstacles

When it comes to microservices, I think it's like calling the API of another service and then calling another service within it.

A -> B -> C If C fails here, B waits for a response until it times out. While B is waiting for a timeout, other requests come in and they also wait for a response until the timeout ... It eats up resources and B also falls. If B falls, there is a concern that a chain of obstacles will occur next, like A.

Reference: Failures and Failurewalls in Microservices https://qiita.com/okumin/items/d7a108ea36f3ad2e3882 The figure was super easy to understand

Circuit Breaker Pattern It seems to be Martin Fowler's saying, XP, refactoring, and people who did java around 2000 should have heard of it. I got a little nervous. https://martinfowler.com/bliki/CircuitBreaker.html It's short, and if you put it in Google Translate, it makes sense.

I think it is easy to understand because there are code and sequence diagrams like implementation examples.

Place a breaker between the client and the called service. It's a pattern that causes the breaker to trip, raise the breaker, and do this automatically.

For example, is it like this?

Summary

As for the mounting itself, the breaker of Manma Electric was exactly as I imagined. A mechanism to prevent a chain of failures when remote access fails. If the service of the callee stops, it doesn't make much sense if the service of the caller cannot continue. Even so, Netflix's Hystrix seems to be able to monitor and monitor, and you may feel that it is a ridiculous atmosphere.

Certainly, Netflix's Hystrix is the Circuit Breaker Pattern, which is Netflix and Bee.

Recommended Posts

Circuit Breaker Pattern I checked
Circuit Breaker Pattern with Apache Camel
I checked this
I checked Zenzenzense, not Zenzenzense
Circuit Breaker Pattern with Apache Camel Part 2 (Try Hystrix Dashboard)
I checked Java Flight Recorder (JFR)