Reputation: 43
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
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
eureka.client.registryFetchIntervalSeconds
ribbon.ServerListRefreshInterval
Upvotes: 9