本文介绍了在Netflix Eureka上以最小的开销寻找合适的开发方法的建议的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们正在运行一个基于Spring Boot的环境,其中包含约15个微服务以及在Eureka注册的Zuul边缘网关.当前,我已经设置了所有微服务以通过Zuul网关调用其他微服务(例如,如果serviceA需要调用serviceB,则URL配置属性为serviceB.baseUrl=http://zuul.mydomain.com:7001,其中zuul.mydomain.com是我们在AWS上与所有其他微服务一起的开发服务器.在它后面运行). Zuul通过Eureka注册表查找反过来代理微服务.

We are running a Spring Boot-based environment with about 15 microservices and a Zuul edge gateway registered with Eureka. Currently, I have set up all microservices to call other microservices through the Zuul gateway (e.g. if serviceA needs to call serviceB, the URL configuration property would be serviceB.baseUrl=http://zuul.mydomain.com:7001 where zuul.mydomain.com is our development server on AWS with all other microservices running behind it). Zuul in turn proxies to the microservices via Eureka registry lookups.

以这种方式进行操作的一个好处是,对于在自己的计算机上本地工作的开发人员而言,他只需要运行服务,就可以通过AWS上的Zuul网关(以及在我们的生态系统中,有很多这样的跨服务依赖项.

One benefit of doing it this way is that for a developer working locally on his machine, he would just need to run his service and all other dependencies on other services are reachable through the Zuul gateway on AWS (and in our ecosystem, there's a lot of such cross-service dependencies).

现在,我真的很想利用Eureka/Ribbon的全部潜能,并通过其服务名称和@LoadBalanced RestTemplate直接调用对等微服务,但是我发现这会给开发人员带来很多麻烦在他的机器上重新创建整个生态系统.至少,他将必须运行Eureka,他自己的服务以及他的服务所依赖的任何其他服务.这使得进入发展的障碍不必要地高.

Now, I would really love to leverage on the full potential of Eureka / Ribbon and make calls directly to a peer microservice via its service name and a @LoadBalanced RestTemplate but I find that this would impose quite a lot on the developer having to recreate an entire ecosystem on his machine. At a minimum, he would have to run Eureka, his own service and any other services that his service is dependent on. This makes the barriers to entry for development unnecessarily high.

我确实考虑过让开发人员的本地实例注册到我们在AWS上的Eureka服务,但是问题是AWS上的所有服务都是使用EC2实例的私有IP注册的,这基本上是开发者的机器无法访问的.如果我强迫该服务使用其公共IP进行注册,那意味着我必须为每个服务用光我们更多的ElasticIP分配,或者每次重新启动EC2实例时都更改IP.

I did consider making the developer's local instance register to our Eureka service on AWS, but the problem is that all services on AWS are registered using the EC2 instance's private IP which is basically unreachable from the developer's machine. If I force the service to register using its public IP, it would mean that I have to use up more of our ElasticIP allocation for each service or change the IP every time the EC2 instance gets rebooted.

我可以在本地网络中运行本地Eureka +微服务环境,但这意味着我需要为我们运营的每个办公室创建一个这样的环境,这意味着更多的开销.除此问题外,这可能意味着开发人员A可能会调用开发人员B的一半(尚未完成)版本的依赖项服务,如果发生问题,该版本只会使所有人困惑.部署到我们的AWS环境中至少要先进行代码审查,然后再部署).

I could run a local Eureka + microservices environment in the local network but that means I need to create one such environment for every office we operate out of and that just means more overheads. In addition to that problem, it would probably mean that developer A may be calling developer B's half-done-not-quite-there-yet version of a dependency service which just confuses the heck out of everyone if a problem occurs (the services that get deployed to our AWS environment at least goes through a code review first before being deployed).

如果有人想出一种方法来简化开发人员的设置,同时又能利用Feign / @LoadBalanced RestTemplate客户端的对等服务调用的可能性,我很乐意向正确的方向指出一些建议.

If there's anybody who has figured out a way to simplify a developer's setup while being able to leverage on the peer-to-peer service invocation possibilities of Feign / @LoadBalanced RestTemplate clients, I would love to get some pointers in the right direction.

推荐答案

已通过以下方式确认我可以完成我想要的工作(即能够在启用了Ribbon的RestTemplate客户端上进行本地开发而不必运行Eureka):

Have confirmed that I can accomplish what I want (which is to be able to do local development on Ribbon enabled RestTemplate clients without having to run Eureka) by:

  1. 使用以下属性强制功能区不使用Eureka:ribbon.eureka.enabled=false
  2. 手动为Ribbon提供服务器以使用以下示例属性来指向它们:servicename.ribbon.listOfServers=test.service.com:8080
  1. Force Ribbon to not use Eureka using the following property: ribbon.eureka.enabled=false
  2. Manually provide Ribbon with the servers to point to using the following sample property: servicename.ribbon.listOfServers=test.service.com:8080

这篇关于在Netflix Eureka上以最小的开销寻找合适的开发方法的建议的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 11:40