maxxx
maxxx

Reputation: 43

zuul fetch new service client slowly

I'm calling my demo-service through Zuul. When I restart the demo-service and noticed it in Eureka, Zuul threw an exception about "Load balancer does not have available server for client: demo-service".

When I keep calling demo-service through Zuul, it only starts to work about after 30 seconds.

eureka server config:

spring.application.name=registry
server.ip=127.0.0.1
server.port=6006

eureka.client.register-with-eureka=false
eureka.client.fetch-registry=false
eureka.client.serviceUrl.defaultZone=http://${server.ip}:${server.port}/eureka/

eureka.server.enable-self-preservation=false
eureka.server.eviction-interval-timer-in-ms=5000

zuul config:

spring.application.name=gateway
server.port=4002

## demo
zuul.routes.api-demo.path=/demo/**
zuul.routes.api-demo.serviceId=demo-service

eureka.client.serviceUrl.defaultZone=http://127.0.0.1:6006/eureka
eureka.instance.prefer-ip-address=true
eureka.client.registryFetchIntervalSeconds=5
logging.level.root=debug

eureka client config(demo-service):

spring.application.name=demo-service
server.port=6020

endpoints.shutdown.enabled=true
endpoints.shutdown.sensitive=false

eureka.client.serviceUrl.defaultZone=http://127.0.0.1:6006/eureka
eureka.instance.prefer-ip-address=true

eureka.instance.lease-renewal-interval-in-seconds=5
eureka.instance.lease-expiration-duration-in-seconds=10

eureka.client.healthcheck.enabled=true

It seems that eureka.client.registryFetchIntervalSeconds=5 in the Zuul config is not working, considering that it takes up to 30 seconds for Zuul to be aware about the demo-service instance. How could I make it work properly?

Upvotes: 4

Views: 2253

Answers (1)

yongsung.yoon
yongsung.yoon

Reputation: 5589

There are many cache layers and intervals between Eureka Client and Eureka Server. So your Eureka client cannot recognize the change of status instantly. But you can reduce the delay with the following properties.

  • eureka.server.responseCacheUpdateInvervalMs
    • define in eureka server.
    • It's eureka server's response cache time of API. Default is 30 seconds and it's too big for most cases. You can reduce this value.
  • eureka.client.registryFetchIntervalSeconds
    • define in eureka client.
    • interval to fetch registry from Eureka Server. You can reduce it.
  • ribbon.ServerListRefreshInterval
    • define in ribbon(eureka) client.
    • Usually Eureka is being used with Ribbon. Therefore, Ribbon's fetching interval is also important to reduce the delay. Default is 30s. You can reduce it.

Upvotes: 9

Related Questions