In a Microservice based system, individual services may fail at any point of time. If a client calls a service frequently, then each call would need to wait for a timeout before failing the operation. Making frequent calls to a failing service and waiting for response wastes system resources and slows down the whole application:
Circuit Breaker(Problem)
The circuit breaker pattern prevents calls to be made to a failing resource once the number of failures cross a particular threshold. To implement the circuit breaker pattern, wrap calls made to a service in a circuit breaker object. The circuit breaker monitors the failures attempts made to the service. Once the number of failed attempts to invoke a service exceeds a threshold value, the circuit trips for that service and any further calls to the service are short-circuited. The circuit breaker may keep the count of failed requests made to the service in a shared cache so that the count may be shared across...