我在 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/