spring 什么是尤里卡服务、尤里卡客户端、尤里卡实例和尤里卡服务器
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/36557646/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
What is Eureka service, Eureka Client, Eureka instance and Eureka server
提问by OD Street
I'm learning spring cloud Netflix by reading this article, however I started to get confused by different terminology in this article, they are:
我正在通过阅读这篇文章来学习 spring cloud Netflix ,但是我开始对本文中的不同术语感到困惑,它们是:
Eureka service.To my understand it's an ordinary service (specifically a Microservice) that running on a unique uri (i.e.one service per uri). Say
localhost:12000
. It is can be registered in the Eureka server.Eureka Client.Same thing as Eureka service???
Eureka Server.To my understand, it's the server that we can inspect, discover and manage bunch of Microservices we built, normally running on
localhost:8761
Eureka Instance.I'm confused by what's it referred to, same thing as the Eureka client?
尤里卡服务。据我所知,它是一个普通的服务(特别是微服务),它运行在一个唯一的 uri(即每个 uri 一个服务)上。说
localhost:12000
。它可以在 Eureka 服务器中注册。尤里卡客户端。和尤里卡服务一样???
尤里卡服务器。据我了解,它是我们可以检查、发现和管理我们构建的通常在其上运行的微服务的服务器
localhost:8761
尤里卡实例。我对它所指的内容感到困惑,与 Eureka 客户端相同吗?
Also in this article, it mentions eureka.client
in config and EurekaClient
in Netflix API, are they referring to the same thing?
同样在本文中,它eureka.client
在 config 和EurekaClient
Netflix API 中提到,它们指的是同一件事吗?
Please tell me what do these four terms mean and correct me if I'm wrong. Thank you!
请告诉我这四个术语是什么意思,如果我错了,请纠正我。谢谢!
==================================UPDATE==================================
==================================更新============== ====================
In the article it said:
文章中说:
@EnableEurekaClient
makes the app into both a Eureka "instance" (i.e. it registers itself) and a "client" (i.e. it can query the registry to locate other services).
@EnableEurekaClient
使应用程序成为 Eureka“实例”(即它自己注册)和“客户端”(即它可以查询注册表以定位其他服务)。
So it looks like the Eureka instance is same as Eureka service. While Eureka Client is a special instance that can query for other instances/services.
所以看起来 Eureka 实例与 Eureka 服务相同。而 Eureka Client 是一个特殊的实例,可以查询其他实例/服务。
采纳答案by ESala
I'd say these terms are used a bit ambiguously, here's what I think they mean in the article:
我想说这些术语的使用有点模棱两可,这是我认为它们在文章中的意思:
Eureka Client: it can be a microservice that is ready to work so it registers itself to the Eureka server e.g. an API for some app, or some application that goes to the server and asks for directions to a specific microservice.
Eureka Instance: a single instance of a microservice (you can add more instances of the same microservice as your load grows i.e. horizontal scaling).
Eureka Service: looks like when you register a microservice as an Eureka Client, you obtain an Eureka Service registered by an ID.
Eureka Server: a server where microservices can register themselves so others can discover them.
Eureka 客户端:它可以是一个准备工作的微服务,因此它可以将自己注册到 Eureka 服务器,例如某个应用程序的 API,或者某个进入服务器并询问特定微服务方向的应用程序。
Eureka Instance:微服务的单个实例(随着负载的增长,您可以添加更多相同微服务的实例,即水平扩展)。
Eureka Service:看起来像当您将微服务注册为 Eureka Client 时,您会获得一个通过 ID 注册的 Eureka Service。
Eureka Server:微服务可以注册自己以便其他人可以发现它们的服务器。
About the update you added:
关于您添加的更新:
Eureka Instanceshould not be confused with Eureka Service. Eureka Servicerefers to the group of microservice instancesregistered to the Eureka Server that provide the same service.
Eureka Instance不应与 Eureka Service混淆。Eureka Service是指注册到 Eureka Server 上提供相同服务的一组微服务实例。
About that @EnableEurekaClient
annotation, it tells the following to the framework: hi there Spring, I am an instance of microservice X, so please register me to the Eureka Server (with eureka.instance.*
properties), and I also want to discover other services, so create the necessary discovery client bean for me (with eureka.client.*
properties).
关于那个@EnableEurekaClient
注解,它告诉框架如下:嗨,Spring,我是微服务X的一个实例,所以请把我注册到Eureka Server(有eureka.instance.*
属性),我也想发现其他服务,所以创建必要的为我发现客户端 bean(带有eureka.client.*
属性)。
In summary, this annotation named @EnableEurekaClientdoes both things, maybe that's where the confusion comes from. But Instanceand Clientare indeed different concepts, even though they are used somewhat interchangeably in the article.
综上所述,这个名为@EnableEureka Client 的注解同时做了两件事,也许这就是混淆的来源。但是Instance和Client确实是不同的概念,尽管它们在文章中有些互换使用。
回答by dustin.schultz
Definitions
定义
Eureka Server
尤里卡服务器
The discovery server. It contains a registry of services and a REST api that can be used to register a service, deregister a service, and discover the location of other services.
发现服务器。它包含一个服务注册表和一个 REST api,可用于注册服务、注销服务和发现其他服务的位置。
Eureka Service
尤里卡服务
Any application that can be found in the Eureka Server's registry and is discoverable by others. A service has a logical identifier sometimes called a VIP, sometimes called a "service id", that can refer to one or more instances of the same application.
可以在 Eureka Server 的注册表中找到并且可以被其他人发现的任何应用程序。服务有一个逻辑标识符,有时称为 VIP,有时称为“服务 ID”,可以指代同一应用程序的一个或多个实例。
Eureka Instance
尤里卡实例
Any application that registers itself with the Eureka Server to be discovered by others
任何在 Eureka 服务器上注册自己以被其他人发现的应用程序
Eureka Client
尤里卡客户端
Any application that can discover services
任何可以发现服务的应用程序
Questions
问题
How can an application be both a Eureka Instance and a Eureka Client?
应用程序如何既是 Eureka 实例又是 Eureka Client?
Applications often need to make themselves available for use by others (so they are an instance) while at the same time they need to discover other services (so they are a client).
应用程序通常需要让自己可供其他人使用(因此它们是一个实例),同时它们需要发现其他服务(因此它们是客户端)。
Does a Eureka Client have to be a Eureka Instance?
Eureka Client 必须是 Eureka 实例吗?
No. Sometimes an application has nothing to offer and is only a caller of other services. Via configuration (eureka.client.register-with-eureka=false
), you can tell it not to register itself as an instance. It is therefore only a Eureka Client as it only discovers other services.
不可以。有时应用程序没有什么可提供的,只是其他服务的调用者。通过配置 ( eureka.client.register-with-eureka=false
),您可以告诉它不要将自己注册为实例。因此它只是一个 Eureka Client,因为它只发现其他服务。
回答by Xian Shu
I think they look like this pic.
我觉得他们看起来像这张照片。
- A Eureka client registers to a Eureka Server.
- Because a Eureka Instance registers to Eureka Server, so it is a client.
- Because a Eureka Service offers api to others, so it can be discovered by others, so it is a Instance.
- Eureka 客户端注册到 Eureka 服务器。
- 因为一个 Eureka Instance 注册到 Eureka Server,所以它是一个客户端。
- 因为一个 Eureka Service 给别人提供了 api,所以它可以被别人发现,所以它是一个 Instance。
回答by Vishwajit Bector
Let's take an example.
让我们举个例子。
Spring-cloud-netflix-turbine uses Eureka to aggregate the metrics from individual micro services. It needs to know address of each instance of micro service running at any time in cloud. The number of instances can go up and down.
Spring-cloud-netflix-turbine 使用 Eureka 聚合来自各个微服务的指标。它需要知道在云中随时运行的每个微服务实例的地址。实例数可以上下浮动。
Eureka Server:Turbine queries Eureka server to get access to registry. Using registry it determines all participating micro services, their end point to reach and more.
Eureka 服务器:Turbine 查询 Eureka 服务器以访问注册表。它使用注册表确定所有参与的微服务、它们要到达的端点等等。
Eureka Service:Information provided by Euerka server to turbine (list of participant Micro Services) is the service. A server could provide multiple services.
Eureka Service:Euerka服务器提供给涡轮的信息(参与者微服务列表)就是服务。一个服务器可以提供多种服务。
Eureka InstanceAll the micro services that want their metrics to be aggregated are Eureka instances. Instances not only can query registry but also register, de-register, provide hear beat to stay registered, etc.
Eureka 实例所有希望聚合其指标的微服务都是 Eureka 实例。实例不仅可以查询注册表,还可以进行注册、注销、提供监听保持注册等功能。
Eureka ClientTurbine is the client. It only queriesregistry to determine running instances of Micro Services.
Eureka ClientTurbine 是客户端。它只查询注册表以确定正在运行的微服务实例。