Introduction To Hystrix

knoldus 587 views 13 slides Jan 07, 2019
Slide 1
Slide 1 of 13
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13

About This Presentation

Hystrix provides us a fault tolerant mechanism using which we can isolate the interaction of our service with other remote systems, services, and third-party libraries. It provides a fallback mechanism to handle the service response whenever something goes wrong. This presentation gives an overview ...


Slide Content

INTRODUCTION TO HYSTRIX By: VINISHA SHARMA (Software Consultant)

Introduction Hystrix working Circuit-breaker Fallback Threadpool Demo AGENDA

Hystrix is a latency and fault tolerance library by Netflix. Designed to isolate points of access to remote systems, services and 3rd party libraries Helps in stopping cascading failures Enable resilience in complex distributed systems where failure is inevitable. WHAT IS HYSTRIX?

Hystrix Command Execute Hystrix command Circuit-breaker Fallback Threads and thread pools Request-caching Request collapsing HOW HYSTRIX WORKS?

Construct HystrixCommand or HystrixObservableCommand object. It represent the request you are making to the dependency. HystrixCommand command = new HystrixCommand(arg1, arg2); Or HystrixObservableCommand command = new HystrixObservableCommand(arg1, arg2); HYSTRIX COMMAND

execute() — blocks, then returns the single response received from the dependency (or throws an exception in case of an error) queue() — returns a Future with which you can obtain the single response from the dependency observe() — subscribes to the Observable that represents the response(s) from the dependency and returns an Observable that replicates that source Observable toObservable() — returns an Observable that, when you subscribe to it, will execute the Hystrix command and emit its responses EXECUTE HYSTRIX COMMAND

When you execute the command, Hystrix checks with the circuit-breaker to see if the circuit is open. If the circuit is open -> Hystrix will not execute and will go to fallback If the circuit is closed -> the flow proceeds to thread pool/semaphore rejection stage to check if there is capacity available to run the command. CIRCUIT BREAKER

Volume across a circuit meets a certain threshold (HystrixCommandProperties.circuitBreakerRequestVolumeThreshold()) And error percentage exceeds the threshold error percentage (HystrixCommandProperties.circuitBreakerErrorThresholdPercentage()) Then the circuit-breaker transitions from CLOSED to OPEN. While it is open, it short-circuits all requests made against that circuit-breaker. Half open state of the circuit WHEN DOES CIRCUIT GET OPEN?

Dependency specific thread pools set by hystrix.threadpool.default.coreSize Default value is 10. If the thread-pool associated with the command is full -> Hystrix will not execute the command and go to fallback THREAD POOL

 Fallback executes when a command execution fails: when an exception is thrown by construct() or run() when the command is short-circuited because the circuit is open when the command’s thread pool and queue or semaphore are at capacity when the command has exceeded its timeout length. HystrixCommand.getFallback() is used for giving fallback FALLBACK

https://github.com/Netflix/Hystrix/wiki/How-it-Works https://github.com/Netflix/Hystrix/wiki/Configuration REFERENCES