Setting Hystrix timeout with environment variable

Michael Técourt picture Michael Técourt · Feb 6, 2017 · Viewed 11.6k times · Source

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.

Answer

jihor picture jihor · Jun 23, 2017

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.