问题
I have a eureka server running with the application.yml looking like
server:
port: 8761
eureka:
client:
registerWithEureka: false
fetch-registry: false
server:
wait-time-in-ms-when-sync-empty: 5
enable-self-preservation: false
and on the client side, I have
eureka:
instance:
prefer-ip-address: true
lease-renewal-interval-in-seconds: 1
lease-expiration-duration-in-seconds: 1
client:
register-with-eureka: true
fetch-registry: true
service-url:
defaultZone: http://localhost:8761/eureka
I specifically put
lease-renewal-interval-in-seconds: 1
lease-expiration-duration-in-seconds: 1
instead of the default for lease-expiration-duration-in-seconds, which is 90.
However, it takes closer to 30 seconds for Eureka to unregister the client, which is similar to how long it would take by default to register the client without the wait-time-in-ms-when-sync-empty: 5 explicitly added in the eureka server's application.yml
Is there a way to speed up the unregistering process? It seems like my attempt to speed up is not working
回答1:
There is one property: evictionIntervalTimerInMs which we need to configure at server side.
server:
enableSelfPreservation: false
evictionIntervalTimerInMs: 1000
This is to run the scheduled job which removes the entry of service from eureka registry. By default it is (60 * 1000) ms. Reduce it to some considerable milliseconds it will work as expected.
Once the lease of your service is cancelled it will be waiting in the eureka's registry till the next eviction job runs. So based on the last run time of eviction job, service entry in registry may reside for 10, 30, 40..seconds.
This property I found after debugging the library. With this property I was able to get the expected behavior. Hope this works for you.
来源:https://stackoverflow.com/questions/51344193/speeding-up-netflix-eureka-unregistration-not-working-for-spring-boot