Posts

Circuit Breaker Pattern

Image
  One of the big differences between in-memory calls and remote calls is that remote calls can fail or hang without a response until some timeout limit is reached.  The basic idea behind the circuit breaker pattern is this: wrap a protected function call in a circuit breaker object, which monitors for failures. Once the failures reach a certain threshold, the circuit breaker trips, and all further calls to the circuit breaker return with an error or with some alternative service or default message, without the protected call being made at all. This will make sure system is responsive and threads are not waiting for an unresponsive call.  The circuit breaker has three distinct states: Closed When everything is normal, all calls pass through to the services. When the number of failures exceeds a threshold the breaker trips, and it goes into the Open state. Open The circuit breaker returns an error for calls without executing the function. Half-Open After a timeout period, the circuit s