SpringCloud中eureka配置心跳和剔除下線的服務的時間


在默認的springCloud中eureka注冊中心在服務下線時表現的非常不靈敏,用慣了dubbo的zk注冊中心表示很不習慣,eureka設計的本意是在服務不會頻繁上下線和網絡穩定的內網,這種設計在生產環境是沒什么問題的,但在開發和測試環境卻會導致經常調用到已經下線的服務提供者,可以加上如下配置來解決(建議配合profile)

1、eureka server中的application.properties

#此配置建議只試用開發和測試環境
#
驅逐下線的服務,間隔,5秒,默認是60 #org.springframework.cloud.netflix.eureka.server.EurekaServerConfigBean.evictionIntervalTimerInMs eureka.server.evictionIntervalTimerInMs=5000

參見類:com.netflix.eureka.registry.AbstractInstanceRegistry

 

2、服務提供者的application.properties

#此配置建議只試用開發和測試環境
#
心跳間隔時間,默認是30秒 #org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.leaseRenewalIntervalInSeconds eureka.instance.leaseRenewalIntervalInSeconds=2 #最后一次心跳時間后leaseExpirationDurationInSeconds秒就認為是下線了,默認是90秒 #org.springframework.cloud.netflix.eureka.EurekaInstanceConfigBean.leaseExpirationDurationInSeconds eureka.instance.leaseExpirationDurationInSeconds=6

 詳細配置項見:org.springframework.cloud.netflix.eureka.EurekaClientConfigBean


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM