Speeding up Netflix-Eureka Unregistration not working for Spring Boot

房东的猫 提交于 2020-01-06 05:34:10

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!