Circuit Breaker Pattern

  • It solve the following problems 
    • Non-transient failures
    • Resilient systems
    • Cascading failures
    • Fault tolerance
    • Retries and recovery
  • It is a cloud design pattern To deal with non-transient failure in micro services.
  • A non-transient failure is a permanent failure that can render the system Unavailable or the recovery can take longer than few seconds.
  • Examples of non-transient failure are
    • Timeout
    • Database failure
    • Connection failure
    • Services bombarded with multiple request and all the request resulting in failure due to memory or CPU issue in application.
    • Circuit breaker helps to Avoid cascading failures, where downtime of one service impacts other dependent services.
  • We try to stop the calls to the failing service until it recovers.
    • The circuit breaker Logic will decide if the request from A will be passed through or rejected or returned with an error.
  • There are three states of circuit breaker
    • Closed
      • When closed all traffic goes as normal.
    • Half open
      • When half open some traffic Go for testing purposes, if the calling service can call downstream service and check if there are any failure or not.
    • Open
      • When the circuit breaker is open The calling service will not be able to call downstream service and will return an error message.
  • When half open if the service recovers, the circuit goes into close, state, else it goes into open state.
  • Default state is closed.
  • After failure, the circuit keeps switching between open and half open state to check recovery.
  • We can make our circuit pattern more efficient by having a control over type of and count of errors.
  • We should also have manual control Over states, for example, if we want to open the circuit breaker, even though services are doing well.
  • We should keep a check on timeout for different states.
  • We should check for concurrency as one service might be getting called from many other services.
  • We should log and monitor different states. 
  • We do not need This, when we have a few services or scenarios, where load is not heavy.
  • Effective way to bring resilience in the systems.
  • Should not be used to solve transient failures.

No comments:

Post a Comment

Recursion

Q What do you understand by a Recursive  Programme? Recursion Is the process of repeating items in a self similar way. In programming langua...