Banpil
Banpil

Reputation: 11

Request not interrupted when HystrixTimeoutException occured

I have a simple Eureka Server, Config Server, Zuul Gateway, and a test service(named aService below) registed in eureka. Besides, a implemention of FallbackProvider is registed and timeoutInMilliseconds for default command is 10000.

I send a request to aService, in which will sleep 15 seconds and print tick per second.After 10 seconds a HystrixTimeoutException occured and my custom fallbackResponse accessed, but the tick still go on until 15 seconds end.

My question is, abviously, why is the request not interrupted?Could someone please explain what hystrix and zuul do after HystrixTimeout?

Dependency version:

        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-commons-dependencies</artifactId>
            <version>Edgware.SR2</version>
        </dependency>
        <dependency>
            <groupId>com.netflix.zuul</groupId>
            <artifactId>zuul-core</artifactId>
            <version>1.3.0</version>
        </dependency>

Some of my hystrix configurations:

zuul.servletPath=/
hystrix.command.default.execution.isolation.strategy=THREAD
hystrix.command.default.execution.isolation.thread.timeoutInMilliseconds=10000
hystrix.command.aService.execution.isolation.strategy=THREAD
ribbon.ReadTimeout=60000
ribbon.ConnectTimeout=3000

Some of my FallbackProvider:

@Component
public class ServerFallback implements FallbackProvider {

  @Override
  public String getRoute() {
    return "*";
  }

  @Override
  public ClientHttpResponse fallbackResponse() {
    // some logs
    return simpleClientHttpResponse();
  }

  @Override
  public ClientHttpResponse fallbackResponse(Throwable cause) {
    // some logs
    return simpleClientHttpResponse();
  }

}
``

Upvotes: 1

Views: 250

Answers (1)

Banpil
Banpil

Reputation: 11

When using zuul with ribbon(default), the executionIsolationStrategy in HytrixCommandProperties will be overrided by AbstractRibbonCommand,which is SEMAPHORE by default.In this isolation strategy, request will not interrupted immediatelly.See ZuulProxy fails with “RibbonCommand timed-out and no fallback available” when it should do failover

Upvotes: 0

Related Questions