How to use circuit breaker pattern of Netflix’s Hystrix library to handle Cascading Failures In Microservices

  1. Binding all calls to external or internal systems (/ “dependency”) during the HystrixCommand or HystrixObservableCommand objects which usually execute in a separate thread.
  2. Timing out calls that take more time(in milliseconds) than the thresholds you define through HystrixCommand.
  3. Maintaining a little thread-pool (/ semaphore) for each dependency; If it becomes full, request destined for that dependency is going to be immediately rejected instead of queued up.
  4. Tripping the circuit breaker that prevent all requests to a specific service for a period of your time , either manually or automatically if the error % for the service exceeds the defined threshold value.
  5. Perform a fallback logic when a call fail/ is rejected /time-out, /short-circuit.
public class Application {
public static void main(String[] arg) {, arg);

public static final String DISPOSE_KEY = "disposeKey";
public static final String DISPOSE_POOL = "disposePool";

@HystrixCommand(commandKey = DISPOSE_KEY, threadPoolKey = DISPOSE_POOL)
public Future<Void> disposeCall(InteractioData interactionData) {


Specialist Programmer, Infosys

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium


Running business during COVID-19 crisis

Observability with RabbitMQ and microservices

Cloud Waste Is Not a Myth: It is a horrifying reality

API Testing using Mobile (Rest Client)

The Singleton Lifestyle

Building a Blockchain: Serialization

Programmable Network — not a pipe dream

I Want To Make An Experiment And I Need Your Help

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Arnab Roy

Arnab Roy

Specialist Programmer, Infosys

More from Medium

Postgresql User Management in Nutshell

Latest features in Java 16

CS371p Spring 2022: Sarunas Budreckis

Importance of ‘null’ in JAVA