5
votes

I have a service that has uses 3 feign clients. Each time I start my application, I get a TimeoutException on the first call to any feign client.

I have to trigger each feign client at least once before everything is stable. Looking around online, the problem is that something inside of feign or hystrix is lazy loaded and the solution was to make a configuration class that overrides the spring defaults. I've tried that wiith the below code and it is still not helping. I still see the same issue. Anyone know a fix for this? Is the only solution to call the feignclient twice via a hystrix callback?

 @FeignClient(value = "SERVICE-NAME", configuration =ServiceFeignConfiguration.class)     

 @Configuration
 public class ServiceFeignConfiguration {

     @Value("${service.feign.connectTimeout:60000}")
     private int connectTimeout;

     @Value("${service.feign.readTimeOut:60000}")
     private int readTimeout;

     @Bean
     public Request.Options options() {
         return new Request.Options(connectTimeout, readTimeout);
     }
 }

Spring Cloud - Brixton.SR4 Spring Boot - 1.4.0.RELEASE

This is all running in docker Ubuntu - 12.04 Docker - 1.12.1 Docker-Compose - 1.8

1
I'd love to see a sample of where the first call always times out. - spencergibb
sounds good, i will add a stacktrace now - GSUgambit
I've seen a timeout stack trace, I'm looking for a sample project that reproduces the problem. Sorry I wasn't clearer. - spencergibb
I have updated to the desc to contain version numbers. I guess incould try to create a githib with a config/eureka/4 micros / and try yo call the other 3 from the 4th. It should show itself then as that's at a basic level, my setup. We have about 10 services at play but I dont think this is a problem woth eureka having a lot of clients registered. Im also using docker and will include those version numbers as well. - GSUgambit

1 Answers

5
votes

I found the solution to be that the default properties of Hystrix are not good. They have a very small timeout window and the request will always time out on the first try. I added these properties to my application.yml file in my config service and now all of my services can use feign with no problems and i dont have to code around the first time timeout

hystrix:
 threadpool.default.coreSize: "20"
 threadpool.default.maxQueueSize: "500000"
 threadpool.default.keepAliveTimeMinutes: "2"
 threadpool.default.queueSizeRejectionThreshold: "500000"
 command:
   default:
     fallback.isolation.semaphore.maxConcurrentRequests: "20"
     execution:
       timeout:
         enabled: "false"
       isolation:
         strategy: "THREAD"
         thread:
           timeoutInMilliseconds: "30000"