javaspringnetflix-eurekaspring-cloud-netflix

How does Eureka lease renewal work?


I have a Eureka server and a Eureka Client. In the bootstrap.properties of the client, I have the below configurations:

eureka.instance.leaseRenewalIntervalInSeconds=240
eureka.instance.leaseExpirationDurationInSeconds=240

My understanding is that the client will send a heartbeat to the server every 240 seconds. If a heartbeat is not got in 240 secs, it will wait for another 240 seconds. If the heartbeat is still not received, it deregisters the client.

However, what I observed is that when I stop the client manually, the Eureka dashboard immediately shows the client as down without waiting for 240s. I was hoping for a delay of at least 240 seconds before the dashboard recognizes the client is down. Can someone explain why is this happening and how can I get the behavior which I have mentioned?


Solution

  • Discovery client (Eureka client) unregisters itself form Eureka server during shutdown. That's why your instance disappears instantly form Eureka server's dashboard when it's shutdown .

    Unfortunately there is no property to disable this behavior as far as I know.

    But you should keep in mind that Eureka server's dashboard displays the current status of registered instances. But Eureka server's APIs have its own response cache. It means that even though your dashboard doesn't show your shutdowned instance, API's response could include your shutdowned instance info during it's cache period.

    You can adjust this server cache period with the below property. The default value is 30 seconds.

    eureka.server.responseCacheUpdateIntervalMs
    

    PS1) changing eureka.instance.leaseRenewalIntervalInSeconds value has some side effect. Some eureka server code assumes that it's 30 seconds. If you change this property, Self Preservation mode might not work properly.

    PS2) Eureka client also has it's own cache. So it will also take some times for Eureka client to recognize the disappearance of your instance.