Skip to main content

The pros and cons of the Circuit Breaker architecture pattern

The Circuit Breaker architecture pattern can provide great benefits for fault tolerant design depending on its implementation.
Image
Three lightbulbs in bright colors

Photo by Daniele Franchi

Having a grasp of common architectural patterns is essential to designing software architecture at scale. Using them saves not only time but also ensures a reliable implementation of your design. There’s no need to reinvent the wheel when there’s an architectural pattern available that applies to an architecture you’re developing.

The following is a brief overview of the Circuit Breaker architectural pattern.

Understanding the Circuit Breaker pattern

The Circuit Breaker pattern is one in which an intermediary service is placed between a caller and a target. The purpose of the intermediary service is to observe conditions in the target. Should hazard occur, the circuit breaker process reroutes traffic to another service that has the logic to mitigate the hazardous condition.

Image
diagram circuit breaker pattern between calling service and two services
Figure 1: The Circuit Breaker Architecture pattern.

Analogically, the pattern is similar to a physical circuit breaker for electric lines. When an electric line becomes overloaded and runs the risk of overheating and causing a fire, the circuit breaker trips and stops electricity from flowing through the circuit’s wire.

Pros

  • Using a circuit breaker to respond to the onset of a hazardous condition in a fault tolerant manner is an excellent way to prevent accidents before they happen. 
  • Provides a good way to make systems fault-tolerant at a fine level of activity.

Cons

  • Testing can be harder than it appears. More is required than simply having the circuit breaker close down access to a particular service. A variety of failure responses need to be in force and these responses need to be tested.
  • Circuits are difficult to do as a one-off. They require an infrastructure management technology such as a service mesh that can manage the switching on and off.

Putting it all together

In terms of addressing failure at a general application level, relying on each process in the system to accommodate failure is a time-consuming undertaking. Making updates at the process level is even more laborious. Using the Circuit Breaker pattern in conjunction with a system management technology such as a service mesh allows software architects to take a global approach to creating fail-safe systems.

Topics:   Architecture patterns  
Author’s photo

Bob Reselman

Bob Reselman is a nationally known software developer, system architect, industry analyst, and technical writer/journalist. More about me

Navigate the shifting technology landscape. Read An architect's guide to multicloud infrastructure.

OUR BEST CONTENT, DELIVERED TO YOUR INBOX

Privacy Statement