vinayan.as vinayan.as - 18 days ago 5
Java Question

why hystrix or any other circuit breaker for a microservice?

I am developing microservice with spring boot and spring cloud. I came to know about hystrix and circuit breaker pattern. I know that circuit breakers are for responding with alternate response in case of errors from downstream microservices on which I depend on to get the data. My question is, if I don't have any meaningful alternative response to provide, why would I need a circuit breaker at all.

Answer

Short answer: mainly to Stop cascading failures in a complex distributed system.

I don't have any meaningful alternative response to provide, why would I need a circuit breaker at all.

This question is relevant only if your server serves just a single REST end point (and a single HTTP verb). But almost always, that's not the case. Even the 'micro'services will have combination of multiple endpoints + multiple http verbs. You don't want one endpoint to hung up on a slow downstream microservice and keep threads waiting there ; because it will eventually bring down your entire application.

Read the official documentation

What Is Hystrix For?

Hystrix is designed to do the following:

  • Give protection from and control over latency and failure from dependencies accessed (typically over the network) via third-party client libraries.
  • Stop cascading failures in a complex distributed system.
  • Fail fast and rapidly recover.
  • Fallback and gracefully degrade when possible.
  • Enable near real-time monitoring, alerting, and operational control.

"Fallback and gracefully degrade when possible" is just one among the features that hystrix offers.

Comments