Setting Hystrix timeout with environment variable

In order to change Hystrix's default request timeout (1000ms), one must set the following property : hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=2000

What is the corresponding environment variable ?

I would like to "tune" the timeout on my favorite cloud platform without touching the source code first. I'm pretty sure this one doesn't work : HYSTRIX_COMMAND_DEFAULT_EXECUTION_ISOLATION_THREAD_TIMEOUT_IN_MILLISECONDS=2000


EDIT : Problem was found with Spring Cloud Camden / Spring Boot 1.4.

Upvotes: 8

Views: 19460

Answers (5)

Anderson
Anderson

Reputation: 2752

VM option -Dhystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=2000 works for me. However it has a side effect, then you can not change the config value in java code since system properties are prioritized.

ConfigurationManager.getConfigInstance().setProperty(
"hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds", 3000);// it doesn't work

Upvotes: 0

jihor
jihor

Reputation: 2599

VM options and environment variables can be referenced from application configuration, which is often a more convenient way to set properties with longer names.

For example, one can define the following reference in application.yml:

hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds: ${service.timeout}

which will be resolved from the VM option -Dservice.timeout=10000, setting the default Hystrix command timeout to 10 seconds. It is even simpler with environment variables - thanks to relaxed binding, any of these will work (export examples are for Linux):

  • export service.timeout=10000
  • export service_timeout=10000
  • export SERVICE.TIMEOUT=10000
  • export SERVICE_TIMEOUT=10000

The common approach is to use lowercase.dot.separated for VM arguments and ALL_CAPS_WITH_UNDERSCORES for environment variables.

Upvotes: 9

Danylo Zatorsky
Danylo Zatorsky

Reputation: 6094

You could try expression with a default value:

hystrix.command.default.execution.isolation.thread.timeoutIn‌Milliseconds: ${SERVICE_TIMEOUT:2000}

In case you have SERVICE_TIMEOUTsystem variable - it will be used by an application, otherwise, a default value will be picked up.

Upvotes: 2

vaquar khan
vaquar khan

Reputation: 11449

You can use Spring config yaml file , Please read further on following link

https://github.com/spring-cloud/spring-cloud-netflix/issues/321

Upvotes: 1

Found more of a workaround than a solution, using SPRING_APPLICATION_JSON environment variable :

SPRING_APPLICATION_JSON='{ "hystrix" : { "command" : { "default" : { "execution" : { "isolation" : { "thread" : { "timeoutInMilliseconds" : 3000 } } } } } } }'

Upvotes: 1

Related Questions