spring - Ribbon 如何检索服务的可用实例列表

标签 spring microservices netflix-eureka netflix-ribbon

我在 API 网关和 Eureka 服务器上使用功能区作为负载平衡器。当客户端请求到达我的 API 网关时,它是每次都查询服务注册表以获取服务的可用实例,还是 Ribbon 将可用实例存储到其缓存中?

最佳答案

Spring Cloud Ribbon 与发现客户端对话以获取有关运行给定服务实例的信息。发现客户端保留了 eureka 注册的内存缓存,以加快查找速度。

您可以查看 Spring Cloud Netflix 文档以获取更多信息:

https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-eureka-server.html

The Eureka server does not have a back end store, but the service instances in the registry all have to send heartbeats to keep their registrations up to date (so this can be done in memory). Clients also have an in-memory cache of Eureka registrations (so they do not have to go to the registry for every request to a service).



另外,对于带有 Eureka 的 Ribbon:
https://cloud.spring.io/spring-cloud-netflix/multi/multi_spring-cloud-ribbon.html#_using_ribbon_with_eureka

When Eureka is used in conjunction with Ribbon (that is, both are on the classpath), the ribbonServerList is overridden with an extension of DiscoveryEnabledNIWSServerList, which populates the list of servers from Eureka.



来自任何区域的客户端都可以查找注册表信息(每 30 秒发生一次)以定位他们的服务(可以在任何区域中)并进行远程调用。更多信息请访问Official Netflix Eureka Documentation

关于spring - Ribbon 如何检索服务的可用实例列表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51783877/

相关文章:

microservices - 微服务架构中的耦合

spring-cloud - 发现客户端的后备 Eureka 服务器配置?

spring - 无法解析 intelliJ 中 EnableEurekaServer 的符号。是的,我有依赖项/无效+重新启动了我的 IDE)

java - Spring REST Jackson - StringBuilder 不与 JSON 绑定(bind)

java - 将 JMockit 模拟注入(inject) Spring 上下文

java - spring-data-solr 创建了错误的 url。两次添加核心名称

从另一个类调用该方法时,DiscoveryClient 上出现 java.lang.NullPointerException

java - 在 JUnit 中使用 @RunWith 有解决方法吗?

docker - 微服务架构中有多少台服务器?

.net-core - 404 尝试将上游路径路由到 Ocelot 中的下游路径