25

I am having same issue, where i am trying to override the hystrix properties in application.yaml. When I run the app & check the properties with localhost:port/app-context/hystrix.stream, I get all default values instead.

here is the hystrix config in my application.yaml

hystrix:
   command.StoreSubmission.execution.isolation.thread.timeoutInMilliseconds: 30000
   command.StoreSubmission.circuitBreaker.requestVolumeThreshold: 4
   command.StoreSubmission.circuitBreaker.sleepWindowInMilliseconds: 60000
   command.StoreSubmission.metrics.rollingStats.timeInMilliseconds: 180000
   collapser.StoreSubmission.maxRequestsInBatch: 1
   collapser.StoreSubmission.requestCache.enabled: FALSE
   threadpool.StoreSubmission.coreSize: 30
   threadpool.StoreSubmission.metrics.rollingStats.timeInMilliseconds: 180000

Here is what I see when I hit the url - localhost:port/app-context/hystrix.stream in browser [ this is same stream url used for hystrix dashboard ] -

data: {"type":"HystrixCommand","name":"storeSubmission","group":"StoreSubmission","currentTime":1435941064801,"isCircuitBreakerOpen":false,"errorPercentage":0,"errorCount":0,"requestCount":0,"rollingCountCollapsedRequests":0,"rollingCountExceptionsThrown":0,"rollingCountFailure":0,"rollingCountFallbackFailure":0,"rollingCountFallbackRejection":0,"rollingCountFallbackSuccess":0,"rollingCountResponsesFromCache":0,"rollingCountSemaphoreRejected":0,"rollingCountShortCircuited":0,"rollingCountSuccess":0,"rollingCountThreadPoolRejected":0,"rollingCountTimeout":0,"currentConcurrentExecutionCount":0,"latencyExecute_mean":0,"latencyExecute":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"latencyTotal_mean":0,"latencyTotal":{"0":0,"25":0,"50":0,"75":0,"90":0,"95":0,"99":0,"99.5":0,"100":0},"propertyValue_circuitBreakerRequestVolumeThreshold":20,"propertyValue_circuitBreakerSleepWindowInMilliseconds":5000,"propertyValue_circuitBreakerErrorThresholdPercentage":50,"propertyValue_circuitBreakerForceOpen":false,"propertyValue_circuitBreakerForceClosed":false,"propertyValue_circuitBreakerEnabled":true,"propertyValue_executionIsolationStrategy":"THREAD","propertyValue_executionIsolationThreadTimeoutInMilliseconds":1000,"propertyValue_executionIsolationThreadInterruptOnTimeout":true,"propertyValue_executionIsolationThreadPoolKeyOverride":null,"propertyValue_executionIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_fallbackIsolationSemaphoreMaxConcurrentRequests":10,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":10000,"propertyValue_requestCacheEnabled":true,"propertyValue_requestLogEnabled":true,"reportingHosts":1}

data: {"type":"HystrixThreadPool","name":"StoreSubmission","currentTime":1435941064801,"currentActiveCount":0,"currentCompletedTaskCount":35,"currentCorePoolSize":30,"currentLargestPoolSize":30,"currentMaximumPoolSize":30,"currentPoolSize":30,"currentQueueSize":0,"currentTaskCount":35,"rollingCountThreadsExecuted":0,"rollingMaxActiveThreads":0,"propertyValue_queueSizeRejectionThreshold":5,"propertyValue_metricsRollingStatisticalWindowInMilliseconds":180000,"reportingHosts":1}

The problem is with hystrix command & collapser properties, where as threadpool properties are set correctly. I have got following annotations in my @configuration class -

@EnableAutoConfiguration(exclude=MongoAutoConfiguration.class)
@EnableHystrix
@EnableHystrixDashboard

Has someone tried configuring hystrix command properties using application.yaml in thier Spring-Boot application, can help please?

Amrut
  • 971
  • 1
  • 9
  • 17
  • I'm looking at this and notice the name coming from the HystrixCommand data is lower case and your configuration is uppercase. – spencergibb Jul 08 '15 at 03:27
  • I pasted your values in my `application.yml` and those values came through. – spencergibb Jul 08 '15 at 03:30
  • @spencergibb: 1. The name coming through in HystrixCommand data is method name which was wrapped by HystrixCommand. 2.In the configuration its groupKey value, actaully this should be commandKey value. 3. When you say these values come up, where? – Amrut Jul 08 '15 at 09:15
  • I am also working on this now & I think I am getting closer to the solution. will post the solution once I have tested it & know it works. – Amrut Jul 08 '15 at 09:20
  • Those values came through the hystrix.stream. – spencergibb Jul 08 '15 at 16:10

1 Answers1

37

The main problem was that, I was using groupKey value instead of commandKey value to define the properties. The wiki page for these configuration properties - https://github.com/Netflix/Hystrix/wiki/Configuration#intro says -

hystrix.command.HystrixCommandKey.execution.isolation.thread.timeoutInMilliseconds

Replace the HystrixCommandKey portion of the property with the value you set for commandkey.

hystrix.threadpool.HystrixThreadPoolKey.coreSize

Replace the HystrixThreadPoolKey portion of the property with the value you set for threadPoolKey.

Here is how I define both commandKey & threadPoolKey over the method wrapped by HystrixCommand -

@HystrixCommand(groupKey = "StoreSubmission", commandKey = "StoreSubmission", threadPoolKey = "StoreSubmission")
public String storeSubmission(ReturnType returnType, InputStream is, String id) {
}

You can actually define both command & threadpool properties on the method within @HystixCommand annotation.

@HystrixCommand(groupKey = "StoreSubmission", commandKey = "StoreSubmission", threadPoolKey = "StoreSubmission", commandProperties = {
        @HystrixProperty(name = "execution.isolation.thread.timeoutInMilliseconds", value = "30000"),
        @HystrixProperty(name = "circuitBreaker.requestVolumeThreshold", value = "4"),
        @HystrixProperty(name = "circuitBreaker.sleepWindowInMilliseconds", value = "60000"),
        @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "180000") }, threadPoolProperties = {
        @HystrixProperty(name = "coreSize", value = "30"),
        @HystrixProperty(name = "metrics.rollingStats.timeInMilliseconds", value = "180000") })
public String storeSubmission(ReturnType returnType, InputStream is, String id) {
}

I guess the best way to define these properties is in externalized application.yaml, that way you can control it better & change them for different environments.

moffeltje
  • 4,521
  • 4
  • 33
  • 57
Amrut
  • 971
  • 1
  • 9
  • 17
  • 2
    Do you know how can I verify that these properties are being applied to configure HystrixCommand? Is there anyway of logging them? Is it possible to enable DEBUG level logging for Hystrix? – pijushcse Feb 23 '18 at 20:52
  • 2
    @pijushcse logging: level: com.netflix.hystrix: 'DEBUG'. First time you enter in the fallback you can see all the values – Aldhor Mar 14 '18 at 12:39
  • From spring-cloud-netflix docs: "The HystrixCommand is provided by a Netflix contrib library called "javanica". Spring Cloud automatically wraps Spring beans with that annotation in a proxy that is connected to the Hystrix circuit breaker. The circuit breaker calculates when to open and close the circuit, and what to do in case of a failure. To configure the HystrixCommand you can use the commandProperties attribute with a list of HystrixProperty annotations." Details: https://github.com/Netflix/Hystrix/tree/master/hystrix-contrib/hystrix-javanica#configuration – maxeh Oct 02 '19 at 09:08
  • What is the purpose of the `groupKey`? Metrics? – wilmol Nov 22 '19 at 06:34
  • @wilmol: GroupKey is used to group together multiple HystrixCommand objects such as for reporting, alerting, dashboard. – Amrut Jan 07 '20 at 11:16
  • What happens when circuitBreaker.requestVolumeThreshold(12) is greater than HystrixThreadPool core size(10). In this case if all the Threads (10) in the ThreadPool got failed, Does Circuit Breaker never opens, because it didn't reach requestVolumeThreshold(12) or how it will execute this scenario? – Sreepad Chitragar Mar 25 '21 at 12:54