1.

What is the difference between using a Circuit Breaker and a naive approach where we try/catch a remote method call and protect for failures?

Answer»

Let's say we want to HANDLE service to service failure GRACEFULLY without using the Circuit Breaker pattern. The naive approach would be to wrap the   REST call in a try-catch clause. But Circuit Breaker does a lot more than try-catch can not accomplish - 

  1. Circuit Breaker does not even try calls once the failure threshold is reached, doing so reduces the number of network calls. Also, a number of THREADS consumed in making faulty calls are freed up.
  2. Circuit breaker provides fallback method execution for gracefully degrading the behavior. Try catch approach will not do this out of the box without additional boiler plate code.
  3. Circuit Breaker can be configured to use a limited number of threads for a particular host/API, doing so brings all the benefits of bulkhead design pattern. 

So instead of WRAPPING service to service calls with try/catch clause, we must use the circuit breaker pattern to make our system resilient to failures.



Discussion

No Comment Found