circuit breaker
play

Circuit Breaker www.thoughts-on-java.org Handle unavailable / - PowerPoint PPT Presentation

Circuit Breaker www.thoughts-on-java.org Handle unavailable / unresponsive services Circuit Breaker Stop if X requests failed Goals Dont block local resource Dont overload unresponsive services Provide fallbacks


  1. Circuit Breaker www.thoughts-on-java.org

  2. • Handle unavailable / unresponsive services Circuit Breaker • Stop if X requests failed • Goals • Don‘t block local resource • Don‘t overload unresponsive services • Provide fallbacks www.thoughts-on-java.org

  3. Spring Cloud Hystrix • Based on Netflix Hystrix • https://github.com/Netflix/hystrix • Spring Cloud Starter • spring-cloud-starter-hystrix www.thoughts-on-java.org

  4. Spring Cloud Hystrix • @EnableCircuitBreaker on configuration class • @HystrixCommand on method • Works within a @Service or @Component • Don‘t call internally www.thoughts-on-java.org

  5. Code Samples www.thoughts-on-java.org

  6. Hystrix Configuration www.thoughts-on-java.org

  7. Hystrix Configuration • Hystrix configuration • https://github.com/Netflix/Hystrix/wiki/Configuration • Set via • @HystrixProperty annotations • External configuration www.thoughts-on-java.org

  8. • execution.isolation.thread.timeoutInMilliseconds Hystrix Property • Timeout in ms for command execution • Default: 1000 www.thoughts-on-java.org

  9. • circuitBreaker.requestVolumeThreshold Hystrix Property • Minimum number of requests to trip the circuit • Default: 20 www.thoughts-on-java.org

  10. • circuitBreaker.errorThresholdPercentage Hystrix Property • Error percentage that trips the circuit • Default: 50 www.thoughts-on-java.org

  11. • circuitBreaker.sleepWindowInMilliseconds Hystrix Property • Time until new attempt • Default: 5000 www.thoughts-on-java.org

  12. • Add commandProperties to @HystrixCommand Annotation-based • Array of @HystrixProperty www.thoughts-on-java.org

  13. Code Samples www.thoughts-on-java.org

  14. • Define commandKey for @HystrixCommand File-based www.thoughts-on-java.org

  15. • Same as annotation-based • Requires prefix File-based • hystrix.command.<CommandKey>.<ParamName> www.thoughts-on-java.org

  16. Code Samples www.thoughts-on-java.org

  17. • Handle unavailable / unresponsive services • Release local resources Summary • Don‘t overload other services • Avoid cascading effects • Provide fallbacks www.thoughts-on-java.org

Recommend


More recommend