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

posted @ 2017-04-19 17:07  自行车上的程序员  阅读(12037)  评论(0编辑  收藏  举报