Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What are Hystrix benefits over normal exception handling?

I'm really new to Hystrix topic and concept of resilient services, I was going through some course and this question came into my mind.

In Hystrix I need to define fallback method for a graceful degradation, this method is then called when circuit is broken. But I can imagine to just wrap code with try and catch and when particular exceptions appear (for timeout for instance) call fallback method in catch clause. When called service is up then normal code would be called.

Of course, with Hystrix I can additionally monitor this, but what else it gives me?. I'm pretty sure that I don't understand whole concept.

like image 749
Artur Skrzydło Avatar asked Sep 18 '17 15:09

Artur Skrzydło


People also ask

What is the purpose of Hystrix?

The Hystrix framework library helps to control the interaction between services by providing fault tolerance and latency tolerance. It improves overall resilience of the system by isolating the failing services and stopping the cascading effect of failures.

What is the use of hystrix in microservices?

Hystrix is a library that controls the interaction between microservices to provide latency and fault tolerance. Additionally, it makes sense to modify the UI to let the user know that something might not have worked as expected or would take more time.

What is the difference between Hystrix and circuit breaker?

The CircuitBreaker can open when too many calls exceed a certain response time threshold, even before the remote system is unresponsive and exceptions are thrown. Hystrix only performs a single execution when in half-open state to determine whether to close a CircuitBreaker.

What is hystrix exception?

An exception representing an error where the provided execution method took longer than the Hystrix timeout.


1 Answers

As you said, it can be simply wrapped under try-catch block then why choose Hystrix or some other library? What i experienced:

  • Already test proven library.
  • Ability to skip original intended calls and fallback. Note that if you wrap it under try-catch, there will be still be an attempt to connect and send command which will eventually timeout due to degraded dependency. Knowing this information prior to call will enable to skip the calls for sometime (as per configuration) and you can save those resources
  • Provides circuit breaking using Sliding Time Window as well
  • Metrics and Dashboarding provided Out of the Box which can help you peek into your system and dependent connection
  • Implements BulkHead by using different Thread Pools
  • Lower maintenance cost
  • Health check ability. It provides a health check class which plugins with Health monitoring APIs
like image 164
Sunil Singhal Avatar answered Sep 17 '22 14:09

Sunil Singhal