了解 Eureka 客户端缓存 [英] Understanding Eureka Client Cache

查看:163
本文介绍了了解 Eureka 客户端缓存的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要一些帮助来理解为什么在 Eureka 中注册的服务尽管实际上并未运行,但仍希望相互通信.例如,我在 Eureka 注册了服务 A 和服务 B.如果我关闭服务 B,服务 A 仍会尝试与服务 B 通信 30 秒到 3 分钟,即使它没有运行.这样做的目的是什么?有什么办法可以解决吗?谢谢!

I need some help understanding why services registered in Eureka would want to communicate with each other despite not actually running. For instance, I have service A and service B registered in Eureka. If I bring down service B, service A will still try to communicate with service B for 30 seconds to 3 minutes even though it is not running. What is the purpose of this? And is there any way around it? Thank you!

推荐答案

如您所知,Netflix 正在运行大量基于 Eureka 的服务器实例.因此,通过 Eureka 查找实例的开销对于 Netflix 来说可能是很大的开销.我想这就是为什么 Eureka 有缓存、轮询间隔等特性会导致刷新实例状态延迟的原因.

As you know, Netflix is running a huge number of server instances based on Eureka. So The overhead to look up instances via Eureka could be big overhead for Netflix. I guess that that's why Eureka has caches, polling intervals and other feature that cause the delay of refreshing instance status.

幸运的是,您可以使用以下属性调整此延迟.

Fortunately, you can adjust this delay with the below properties.

  • Eureka 服务器 - eureka.server.responseCacheUpdateInvervalMs

  • 30 秒.Eureka 服务器的 API 有自己的响应缓存.默认是相当大的时期.您可以减小此值.

Eureka 客户端(API 调用方) - eureka.client.registryFetchIntervalSeconds

  • 30 秒.Eureka 客户端定期从 Eureka 服务器获取实例状态.您可以减小此值.

Eureka 客户端(API 提供商) eureka.instance.leaseExpirationDurationInSeconds

  • 90 秒.每个注册到 Eureka 服务器的实例都可以为自己设置过期时间.如果在此期间 Eureka 服务器没有收到来自 Eureka 客户端的任何心跳,则 Eureka 服务器实例到期.默认情况下,每个 Eureka 客户端每 30 秒发送一次心跳.

如果您运行的实例数量不是很大,您通常可以减少上述属性.

If the number of instances that you're running is not so big, you can usually decrease above properties.

还有另一个与此延迟相关的属性.

There is another property related to this delay.

  • eureka.instance.leaseRenewalIntervalInSeconds

该属性设置 Eureka 客户端的心跳间隔.它的默认值为 30 秒,但您无法调整此值,因为 Eureka 服务器有一些硬编码逻辑,假设此时间段为 30 秒.

This property set the interval of heartbeat for Eureka client. Its default is 30 seconds, but you can't adjust this value because Eureka server has some hardcoded logic that assumes this period is 30 seconds.

这篇关于了解 Eureka 客户端缓存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆