Eureka 健康检查

1.Eureka原理图

在这里插入图片描述
服务在Eureka 注册,然后发送心跳每30秒更新一次租约。如果客户端无法续订租,则会在90秒内将其从服务器注册表中删除。注册信息和续订将复制到群集中的所有eureka节点。来自任何区域的客户端都可以查找注册表信息(每30秒发生一次)以查找其服务(可能位于任何区域中)并进行远程调用。

2.Eureka健康检查

默认情况下,Eureka使用客户端心跳来确定客户端是否已启动。在成功注册后,Eureka始终宣布应用程序处于“UP”状态。
通过启用Eureka运行状况检查可以更改此行为,从而将应用程序状态传播到Eureka。这样,每个其他应用程序都不会向“UP”以外的状态下的应用程序发送流量。
Eureka的健康检查依赖于Springboot-actuator的/health
以下示例显示如何为客户端启用运行状况检查:

eureka:
  client:
    healthcheck:
      enabled: true

3.配置参数

eureka.instance.initial-status 默认是up
Initial status to register with remote Eureka server.
注册远程Eureka服务器的初始状态。

eureka.client.fetch-registry 默认是true
Indicates whether this client should fetch eureka registry information from eureka server.
指示此客户端是否应从eureka服务器获取eureka注册表信息

eureka.client.registry-fetch-interval-seconds 默认30秒
Indicates how often(in seconds) to fetch the registry information from the eureka server.
指示从eureka服务器获取注册表信息的频率(以秒为单位)。

instance-info-replication-interval-seconds 默认30秒
Indicates how often(in seconds) to replicate instance changes to be replicated to the eureka server.
指示复制要复制到eureka服务器的实例更改的频率(以秒为单位)。
健康检查的频率
每隔30秒扫描一次本地实例,如果有变化向服务重新注册

eureka.instance.lease-renewal-interval-in-seconds 默认30
Indicates how often (in seconds) the eureka client needs to send heartbeats to eureka server to indicate that it is still alive. If the heartbeats are not received for the period specified in leaseExpirationDurationInSeconds, eureka server will remove the instance from its view, there by disallowing traffic to this instance. Note that the instance could still not take traffic if it implements HealthCheckCallback and then decides to make itself unavailable.
指示eureka客户端向Eureka服务器发送心跳以指示其仍处于活动状态所需的频率(以秒为单位)。如果在leaseExpirationDurationInSeconds中指定的时间段内未收到心跳,则eureka服务器将从其视图中删除该实例,此处不允许此实例的流量。请注意,如果实例实现HealthCheckCallback,然后决定使其自身不可用,则实例仍然无法获取流量。

eureka.instance.lease-expiration-duration-in-seconds 默认90
Indicates the time in seconds that the eureka server waits since it received the last heartbeat before it can remove this instance from its view and there by disallowing traffic to this instance. Setting this value too long could mean that the traffic could be routed to the instance even though the instance is not alive. Setting this value too small could mean, the instance may be taken out of traffic because of temporary network glitches.This value to be set to atleast higher than the value specified in leaseRenewalIntervalInSeconds.
指示eureka服务器在从其视图中删除此实例之前收到最后一次心跳之后等待的时间(以秒为单位),并禁止此流量通过此实例。将此值设置得太长可能意味着即使实例不活动,流量也可以路由到实例。将此值设置得太小可能意味着,由于临时网络故障,实例可能会被取消流量。此值设置为至少高于leaseRenewalIntervalInSeconds中指定的值。

猜你喜欢

转载自blog.csdn.net/huiyanshizhen21/article/details/89513902