Hystrix & Ribbon Timeout Warnings
Asked Answered
I

1

7

Environment

  • Spring Boot 1.5.13.RELEASE
  • Spring Cloud Edgware.SR3
  • Compiled with Java version "1.8.0_172-ea",Java(TM) SE Runtime Environment (build 1.8.0_172-ea-b03) and source level 1.8
  • Runtime JRE: in docker with openjdk:10.0.1-jre-slim

Question

I have a ribbon client called serviceA and associated

serviceA.ribbon.ConnectTimeout=5000
serviceA.ribbon.ReadTimeout=15000
hystrix.command.serviceA.execution.isolation.thread.timeoutInMilliseconds = 20000

I have not (knowingly) got spring-retry on the classpath. I execute ./mvnw dependency:list | grep -i retry and get no results.

At runtime I get these warnings:

The Hystrix timeout of 20000ms for the command serviceA is set lower than the combination of the Ribbon read and connect timeout, 40000ms.

I'm not sure where these numbers come from given that I thought I'd set them to 15 and 5 seconds respectively. Why is this figure double?

Illusive answered 31/5, 2018 at 10:55 Comment(0)
C
24

Actually, ribbon timeout includes all same server retry and next server retry.

ribbonTimeout = (ribbon.ConnectTimeout + ribbon.ReadTimeout) * (ribbon.MaxAutoRetries + 1) * (ribbon.MaxAutoRetriesNextServer + 1);
// ...
if(hystrixTimeout < ribbonTimeout) {
        LOGGER.warn("The Hystrix timeout of " + hystrixTimeout + "ms for the command " + commandKey +
            " is set lower than the combination of the Ribbon read and connect timeout, " + ribbonTimeout + "ms.");
    }

In your configuration:

  • ribbon.connectionTimeout is 5000
  • ribbon.readTimeout is 15000
  • ribbon.maxAutoRetries is 0 (default)
  • ribbon.maxAutoRetriesNextServer is 1 (default)

So the hystrixTimeout should be:

(5000 + 15000) * (1 + 0) * (1 + 1) // -> 40000 ms

If you choose to not configure Hystrix timeout, the default Hystrix timeout will be 40000ms.

19.13 Zuul Timeouts in Spring Cloud Document

Cloth answered 5/6, 2018 at 6:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.