Importance Of Circuit Breaker In Microservices

What are the Circuit Breakers? Why do we need them?

Vinesh
The Jabberjays

--

In recent times we build all applications using Microservice architecture, so how robust is this implementation? What problems will we face if a microservice fails? Let’s see all these aspects and how Circuit Breaker implementation can solve those issues.

Failures in Microservices

Let’s say we have a set of microservices, we have Order Service on the left and Payment Service on the right. To fulfill an order, the Order Service needs to talk with the Payment Service. If we are using Spring Boot, the Order Service has a Servlet Thread Pool and for each incoming request, a thread will be assigned from the Thread pool to serve the request. The thread will do the request processing and once the response is sent back to the user, the thread will be freed.

With this approach we might face 2 kinds of failures:

  1. Immediate Failure: Let’s say the Order Service gets a request and a thread is assigned, whenever it tries to make a call to the payment service, it immediately sends an exception Connection…

--

--

Vinesh
The Jabberjays

Coder 👨‍💻, Gamer🎮 and a dog person🐶. That says a lot about me, I guess😛.