Implementing Circuit Breaker Pattern Using Spring Cloud Hystrix

Spring Cloud Hystrix is another important component of the Spring Cloud project. It is used to implement the Circuit Breaker pattern. The role of the circuit breaker is to enable fault tolerance in a microservice architecture in case some underlying service is down.

In other words, using a circuit breaker, we can fall back to a different path of the program automatically. Spring Cloud Hystrix helps make the switch seamless.

Spring Cloud and Turbine

In this article, we'll introduce you to Spring Cloud Netflix Turbine. It aggregates multiple Hystrix Metrics Streams into one, so that it could be displayed into a single dashboard view.

To give a small introduction to Hystrix. In a microservice architecture, we have many small applications that talk to each other to complete a request.

Circuit Breaker Design Pattern Using Netflix Hystrix

Check out this circuit design!
You may also like: Design Patterns in Java: Singleton

1. Introduction

A circuit breaker is an electronic/electrical component that makes a circuit open so that no current can flow through it. It is used to prevent the damage caused by excess current from an overload or short circuit.

Generally, fuses are considered to be a circuit breaker, but there is a subtle difference between circuit breakers and fuses. Fuses operate once and must be replaced but the circuit breaker can be reset to resume the normal operation.