Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hystrix & Ribbon Timeout Warnings

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?

like image 624
David Avatar asked May 31 '18 10:05

David


People also ask

What is Hystrix used for?

The Hystrix framework library helps to control the interaction between services by providing fault tolerance and latency tolerance. It improves overall resilience of the system by isolating the failing services and stopping the cascading effect of failures.

What is Hystrix in Microservices?

Hystrix is a library that controls the interaction between microservices to provide latency and fault tolerance. Additionally, it makes sense to modify the UI to let the user know that something might not have worked as expected or would take more time.

Is Hystrix a circuit breaker?

It makes more sense for the service to back off and give calls to the callee service after some time or share default response. Netflix Hystrix, Resilince4j are two well-known circuit breakers which are used to handle such situations.

Does Netflix still use Hystrix?

Hystrix Status. Hystrix is no longer in active development, and is currently in maintenance mode. Hystrix (at version 1.5. 18) is stable enough to meet the needs of Netflix for our existing applications.


1 Answers

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

like image 126
bootsoon Avatar answered Oct 31 '22 22:10

bootsoon