5

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

GSUgambit
  • 4,459
  • 6
  • 25
  • 31
  • I'd love to see a sample of where the first call always times out. – spencergibb Sep 20 '16 at 20:04
  • sounds good, i will add a stacktrace now – GSUgambit Sep 20 '16 at 20:12
  • I've seen a timeout stack trace, I'm looking for a sample project that reproduces the problem. Sorry I wasn't clearer. – spencergibb Sep 21 '16 at 01:59
  • 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 Sep 22 '16 at 08:11
  • See the https://stackoverflow.com/a/44932243/2935802 – Sudhakar Jul 06 '17 at 05:44

1 Answers1

5

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"
GSUgambit
  • 4,459
  • 6
  • 25
  • 31
  • 1
    You are missing the point of using Hystrix: preventing requests to pile up (making the entire system unavailable) when one of the subsequent systems is not there or responds too slow. By increasing the timeout to 30 seconds you still risk locking up the entire system, instead of letting hystrix open the circuit to the slow application (and let it recover) – dvtoever Jan 18 '17 at 10:08
  • @dvtover the system can still have the circuit open and you can use fallbacks etc. With these configurations you just dont have to code around "is this the first call and that's why hystrix is failing" – GSUgambit Feb 01 '17 at 23:35
  • When you say "config service" are you referring to your config server app in your spring cloud project? I am also facing the same problem and I have similar configuration on my Zuul gateway project but not my actual service projects. Do I have to enter these config in individual projects which is using Feign client? – Sayantan Aug 05 '17 at 17:51
  • @Sayantan I'm sorry, I'm just seeing your response, yes I meant config server instead of config service – GSUgambit Nov 19 '17 at 03:13