Spring Boot microservices are not loading eagerly, first request takes too long

Viewed 456

I have a system of microservices based on Spring Cloud: Zuul, Eureka, Hystrix, Ribbon, Feign.

For authentication process the chain of requests looks like "gateway -> auth-service -> user-service". I had a problem with TimeoutException during first request and solved it by changing ribbon's timeout properties. Now everything works but it's still not good because first request takes more than 2-3 seconds (other requests take less than 50ms). I have set eager-load property but it doesn't change anything.

The relevant part of application.yml (common for all services):

# CLOUD
eureka:
  client:
    region: default
    registryFetchIntervalSeconds: 5
hystrix:
  command:
    default:
      execution:
        isolation:
          strategy: THREAD
          thread:
            timeoutInMilliseconds: 20000
ribbon:
  eager-load:
    enabled: true
    clients: gateway, registry, auth-service, user-service, mail-service
  ReadTimeout: 5000
  ConnectTimeout: 5000

Part of gateway's config:

# GATEWAY
zuul:
  ribbon:
    eager-load:
      enabled: true

Typical service has this spring cloud dependencies with version Hoxton.SR5. Gateway has Zuul in addition.

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-netflix-hystrix-dashboard</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-zipkin</artifactId>
</dependency>

One more important notice: every service runs in own docker container.

Have you any ideas what am I doing wrong? Thanks!

0 Answers
Related