Design patterns – circuit breaker

In this section, we will discuss the circuit breaker pattern. Before that, let's think about any microservice architecture in which one service is synchronously invoked by other services. What if one service breaks down? This could be due to high latency, a code issue, or limited resources. The failure of one service can lead to other services failing throughout the application. To manage this problem and prevent a cascading service failure, we can use a circuit breaker. This is more than a design pattern; we can think of it as a sustainable pattern, which means that it can help prevent our microservices from dying.

Everything fails, accept it! A circuit breaker can help us solve our problems.

Think about your own personal electricity supply. You might get power from the main grid, and it might come through a circuit breaker. If a lighting strike causes additional power to surge on the power grid, it will break the circuit breaker. The circuit breaker will therefore protect your internal wiring and the electrical system in your home. In the microservice world, circuit breakers work in exactly the same way that is if a service goes down or fails: it will stop all the calls and requests to that particular service and instead return cached data or a timeout error.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset