简体   繁体   English

什么是尤里卡服务、尤里卡客户端、尤里卡实例和尤里卡服务器

[英]What is Eureka service, Eureka Client, Eureka instance and Eureka server

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,但是我开始对本文中的不同术语感到困惑,它们是:

  1. Eureka service.尤里卡服务。 To my understand it's an ordinary service (specifically a Microservice) that running on a unique uri (ieone service per uri).据我所知,它是一个普通的服务(特别是微服务),它运行在一个唯一的 uri(即每个 uri 一个服务)上。 Say localhost:12000 .localhost:12000 It is can be registered in the Eureka server.它可以在 Eureka 服务器中注册。

  2. Eureka Client.尤里卡客户端。 Same thing as Eureka service???和尤里卡服务一样???

  3. 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据我所知,它是我们可以检查、发现和管理我们构建的一堆微服务的服务器,通常在localhost:8761上运行

  4. Eureka Instance.尤里卡实例。 I'm confused by what's it referred to, same thing as the Eureka client?我对它所指的内容感到困惑,与 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在配置和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" (ie it registers itself) and a "client" (ie it can query the registry to locate other services). @EnableEurekaClient使应用程序成为 Eureka“实例”(即它自己注册)和“客户端”(即它可以查询注册表以定位其他服务)。

So it looks like the Eureka instance is same as Eureka service.所以看起来 Eureka 实例与 Eureka 服务相同。 While Eureka Client is a special instance that can query for other instances/services.而 Eureka Client 是一个特殊的实例,可以查询其他实例/服务。

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.可以在 Eureka Server 的注册表中找到并且可以被其他人发现的任何应用程序。 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.服务有一个逻辑标识符,有时称为 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.通过配置( eureka.client.register-with-eureka=false ),您可以告诉它不要将自己注册为实例。 It is therefore only a Eureka Client as it only discovers other services.因此它只是一个 Eureka Client,因为它只发现其他服务。

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 eg an API for some app, or some application that goes to the server and asks for directions to a specific microservice. Eureka 客户端:它可以是一个准备工作的微服务,因此它可以将自己注册到 Eureka 服务器,例如某个应用程序的 API,或者某个进入服务器并询问特定微服务方向的应用程序。

  • Eureka Instance : a single instance of a microservice (you can add more instances of the same microservice as your load grows ie horizontal scaling). Eureka Instance :微服务的单个实例(随着负载的增长,您可以添加更多相同微服务的实例,即水平扩展)。

  • Eureka Service : looks like when you register a microservice as an Eureka Client, you obtain an Eureka Service registered by an ID. Eureka Service :看起来像当您将微服务注册为 Eureka Client 时,您会获得一个通过 ID 注册的 Eureka Service。

  • Eureka Server : a server where microservices can register themselves so others can discover them. Eureka Server :微服务可以注册自己以便其他人可以发现它们的服务器。


About the update you added:关于您添加的更新:

Eureka Instance should not be confused with Eureka Service . Eureka Instance不应与 Eureka Service混淆。 Eureka Service refers to the group of microservice instances registered to the Eureka Server that provide the same 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 @EnableEureka Client does both things, maybe that's where the confusion comes from.综上所述,这个名为@EnableEureka Client 的注解同时做了两件事,也许这就是混淆的来源。 But Instance and Client are indeed different concepts, even though they are used somewhat interchangeably in the article.但是InstanceClient确实是不同的概念,尽管它们在文章中有些互换使用。

在此处输入图片说明

I think they look like this pic.我觉得他们看起来像这张照片。

  1. A Eureka client registers to a Eureka Server. Eureka 客户端注册到 Eureka 服务器。
  2. Because a Eureka Instance registers to Eureka Server, so it is a client.因为一个 Eureka Instance 注册到 Eureka Server,所以它是一个客户端。
  3. Because a Eureka Service offers api to others, so it can be discovered by others, so it is a Instance.因为一个 Eureka Service 给别人提供了 api,所以它可以被别人发现,所以它是一个 Instance。

Let's take an example.让我们举个例子。

Spring-cloud-netflix-turbine uses Eureka to aggregate the metrics from individual micro services. Spring-cloud-netflix-turbine 使用 Eureka 聚合来自各个微服务的指标。 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.实例数可以上下浮动。

Eureka Server: Turbine queries Eureka server to get access to registry. Eureka 服务器: Turbine 查询 Eureka 服务器以访问注册表。 Using registry it determines all participating micro services, their end point to reach and more.它使用注册表确定所有参与的微服务、它们要到达的端点等等。

Eureka Service: Information provided by Euerka server to turbine (list of participant Micro Services) is the service. Eureka Service: Euerka服务器提供给涡轮的信息(参与者微服务列表)就是服务。 A server could provide multiple services.一个服务器可以提供多种服务。

Eureka Instance All the micro services that want their metrics to be aggregated are Eureka instances. Eureka 实例所有希望聚合其指标的微服务都是 Eureka 实例。 Instances not only can query registry but also register, de-register, provide hear beat to stay registered, etc.实例不仅可以查询注册表,还可以进行注册、注销、提供监听保持注册等功能。

Eureka Client Turbine is the client. Eureka Client Turbine 是客户端。 It only queries registry to determine running instances of Micro Services.它只查询注册表以确定正在运行的微服务实例。

From the official documentation :从官方文档

Eureka comes with two components - Eureka Client and the Eureka Server. Eureka 带有两个组件 - Eureka Client 和 Eureka Server。 Your architecture which is using Eureka will typically have two applications您使用 Eureka 的架构通常有两个应用程序

  1. Application Client which uses Eureka Client to make requests to the Application Service. Application Client 使用 Eureka Client 向 Application Service 发出请求。
  2. Application Service which receives requests from Application Client and sends a response back.应用程序服务,它接收来自应用程序客户端的请求并返回响应。

The setups involve the following设置涉及以下内容

  1. Eureka Server - This keeps a record of all the services which have registered. Eureka Server - 这会记录所有已注册的服务。
  2. Eureka Client for the application client应用程序客户端的 Eureka Client
  3. Eureka Client for the application service应用服务的 Eureka Client

Eureka Instance means a single node of the Application client. Eureka Instance表示应用程序客户端的单个节点。

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM