Eureka服务注册与发现组件介绍

什么是Eureka?

Eureka is a REST (Representational State Transfer) based service that is primarily used in the AWS cloud for locating services for the purpose of load balancing and failover of middle-tier servers. We call this service, the Eureka Server. Eureka also comes with a Java-based client component,the Eureka Client, which makes interactions with the service much easier. The client also has a built-in load balancer that does basic round-robin load balancing. At Netflix, a much more sophisticated load balancer wraps Eureka to provide weighted load balancing based on several factors like traffic, resource usage, error conditions etc to provide superior resiliency.

Eureka是一种基于REST(Representational State Transfer)的服务,主要用于AWS云,用于定位服务,以实现中间层服务器的负载平衡和故障转移。我们将此服务称为Eureka Server。Eureka还附带了一个基于Java的客户端组件Eureka Client,它使与服务的交互变得更加容易。客户端还有一个内置的负载均衡器,可以进行基本的循环负载均衡。在Netflix,一个更复杂的负载均衡器包装Eureka,根据流量,资源使用,错误条件等多种因素提供加权负载平衡,以提供卓越的弹性。

Eureka能解决什么问题 ?

In AWS cloud, because of its inherent nature, servers come and go. Unlike the traditional load balancers which work with servers with well known IP addresses and host names, in AWS, load balancing requires much more sophistication in registering and de-registering servers with load balancer on the fly. Since AWS does not yet provide a middle tier load balancer, Eureka fills a big gap in the area of mid-tier load balancing.

在AWS云中,由于其固有的特性,服务器来来去去。与使用具有众所周知的IP地址和主机名的服务器的传统负载均衡器不同,在AWS中,负载均衡在使用负载均衡器注册和取消注册服务器时需要更加复杂。由于AWS尚未提供中间层负载均衡器,因此Eureka填补了中端负载均衡领域的巨大空白。

它与AWS的ELB的不同之处?

AWS Elastic Load Balancer is a load balancing solution for edge services exposed to end-user web traffic. Eureka fills the need for mid-tier load balancing. While you can theoretically put your mid-tier services behind the AWS ELB, in EC2 classic you expose them to the outside world and there by losing all the usefulness of the AWS security groups.

AWS ELB is also a traditional proxy-based load balancing solution whereas with Eureka it is different in that the load balancing happens at the instance/server/host level. The client instances know all the information about which servers they need to talk to. This is a blessing or a curse depending on which way you look at it. If you are looking for a sticky user session based load balancing which AWS now offers, Eureka does not offer a solution out of the box. At Netflix, we prefer our services to be stateless (non-sticky). This facilitates a much better scalability model and Eureka is well suited to address this.

Another important aspect that differentiates proxy-based load balancing from load balancing using Eureka is that your application can be resilient to the outages of the load balancers, since the information regarding the available servers is cached on the client. This does require a small amount of memory, but buys better resiliency.

AWS Elastic Load Balancer是面向最终用户Web流量的边缘服务的负载平衡解决方案。Eureka满足了中层负载平衡的需求。虽然理论上您可以将您的中间层服务置于AWS ELB之后,但在EC2 classic中,您会将它们暴露给外部世界,从而失去AWS安全组的所有实用性。

AWS ELB也是传统的基于代理的负载平衡解决方案,而与Eureka不同的是,负载平衡发生在实例/服务器/主机级别。客户端实例知道他们需要与哪些服务器通信的所有信息。这是一种祝福或诅咒,取决于你看待它的方式。如果您正在寻找AWS现在提供的基于粘性用户会话的负载平衡,Eureka不提供开箱即用的解决方案。在Netflix,我们更喜欢我们的服务是无状态(非粘性)。这有助于实现更好的可扩展性模型,Eureka非常适合解决这个问题。

使用Eureka将基于代理负载均衡与负载均衡区分开来的另一个重要方面是,您的应用程序可以适应负载均衡器的中断,因为有关可用服务器的信息会缓存在客户端上。这确实需要少量内存,但可以获得更好的弹性。

 它与Route 53的不同之处是什么?

Route 53 is a naming service, like which Eureka can provide the same for the mid-tier servers, but the similarity stops there. Route 53 is a DNS service which can host your DNS records even for non-AWS data centers. Route 53 can also do latency based routing across AWS regions. Eureka is analogous to internal DNS and has nothing to do with the DNS servers across the world. Eureka is also region-isolated in the sense that it does not know about servers in other AWS regions. It's primary purpose of holding information is for load balancing within a region.

While you can register your mid-tier servers with Route 53 and rely on AWS security groups to protect your servers from public access, your mid-tier server identity is still exposed to the external world. It also comes with the drawback of the traditional DNS based load balancing solutions where the traffic can still be routed to servers which may not be healthy or may not even exist (in the case of AWS cloud where servers can disappear anytime).

Route 53是一个名称服务,Eureka可以为中间层服务器提供相同的服务,但他们的相似之处也仅此而已。Route 53是一种DNS服务,即使对于非AWS数据中心,它也可以托管您的DNS记录。Route 53还可以跨AWS区域执行基于延迟的路由。Eureka类似于内部DNS,与世界各地的DNS服务器无关。Eureka也是区域隔离的,因为它不了解其他AWS区域中的服务器。保存信息的主要目的是在区域内进行负载平衡。

虽然您可以使用Route 53注册中间层服务器并依赖AWS安全组来保护您的服务器免受公共访问,但您的中间层服务器身份仍然会暴露给外部世界。它还具有传统的基于DNS的负载平衡解决方案的缺点,其中流量仍然可以路由到可能不健康或甚至不存在的服务器(在AWS云的情况下,服务器可以随时消失)。

Eureka如何在Netflix上使用?

At Netflix, Eureka is used for the following purposes apart from playing a critical part in mid-tier load balancing.

  • For red/black deployments with Netflix Asgard- an open source service which makes cloud deployment easier. Eureka interacts with Asgard to make switching between older/newer release of a deployment of services quick and seamless in case of problems - especially given that launching 100's of instances to deploy a release could take a long time.

  • For our cassandra deployments to take instances out of traffic for maintenance.

  • For our memcached caching services to identify the list of nodes in the ring.

  • Used for carrying other additional application specific metadata about services for various other reasons.

 在Netflix,除了在中间层负载平衡中起关键作用之外,Eureka还用于以下目的:

  • 使用Netflix Asgard进行红/黑部署 - 一种开源服务,可以更轻松地部署云。Eureka与Asgard进行交互,以便在出现问题时快速无缝地在服务部署的旧版本/新版本之间进行切换 - 特别是考虑到启动100个实例来部署版本可能需要很长时间。
  • 可用于我们的cassandra部署,将实例从流量中取出进行维护。
  • 可用于我们的memcached缓存服务,来识别环中的节点列表。
  • 可用于出于各种其他原因携带有关服务的其他特定应用程序元数据。

Eureka的使用场景?

You typically run in the AWS cloud and you have a host of middle tier services which you do not want to register with AWS ELB or expose traffic from outside world. You are either looking for a simple round-robin load balancing solution or are willing to write your own wrapper around Eureka based on your load balancing need. You do not have the need for sticky sessions and load session data in an external cache such as memcached. More importantly, if your architecture fits the model where a client based load balancer is favored, Eureka is well positioned to fit that usage.

如果您的服务通常在AWS云中运行,并且您有许多中间层服务,您不希望向AWS ELB注册或暴露来自外部世界的流量。您要么寻找简单的循环负载平衡解决方案,要么愿意根据负载平衡需求在Eureka周围编写自己的包装器。您不需要粘性会话并在外部缓存(例如memcached)中加载会话数据。更重要的是,如果您的架构适合基于客户端的负载均衡器的模型,Eureka可以很好地适应这种用法。

 应用程序客户端和应用程序服务器如何通信?

The communication technology could be anything you like. Eureka helps you find the information about the services you would want to communicate with but does not impose any restrictions on the protocol or method of communication. For instance, you can use Eureka to obtain the target server address and use protocols such as thrift, http(s) or any other RPC mechanisms

它们之间通信方式能如你所愿。Eureka可帮助您查找有关您希望与之通信的服务的信息,但不会对协议或通信方法施加任何限制。例如,您可以使用Eureka获取目标服务器地址并使用诸如thrift,http(s)或任何其他RPC机制之类的协议。

Eureka高阶架构

 Eureka High level Architecture

The architecture above depicts how Eureka is deployed at Netflix and this is how you would typically run it. There is one eureka cluster per region which knows only about instances in its region. There is at the least one eureka server per zone to handle zone failures.

Services register with Eureka and then send heartbeats to renew their leases every 30 seconds. If the client cannot renew the lease for a few times, it is taken out of the server registry in about 90 seconds. The registration information and the renewals are replicated to all the eureka nodes in the cluster. The clients from any zone can look up the registry information (happens every 30 seconds) to locate their services (which could be in any zone) and make remote calls.

上面的架构图描述了如何在Netflix上部署Eureka,这就是您通常运行它的方式。每个地区只有一个Eureka群集,它只知道该地区的实例。每个区域至少有一个eureka服务器来处理区域故障。服务在Eureka注册,然后每30秒发送一次心跳更新一次租约。如果客户端无法续租几次,则会在大约90秒内将其从服务器注册表中剔除。注册信息和续订将复制到群集中的所有eureka节点。来自任何区域的客户端都可以查找注册表信息(每30秒发生一次)以查找其服务(可能位于任何区域中)并进行远程调用。

非Java服务和客户端

For services that are non-Java based, you have a choice of implementing the client part of eureka in the language of the service or you can run a "side car" which is essentially a Java application with an embedded eureka client that handles the registrations and heartbeats. REST based endpoints are also exposed for all operations that are supported by the Eureka client. Non-Java clients can use the REST end points to query for information about other services.

对于那些非Java构建的服务,您可以选择以服务语言实现eureka的客户端,或者您可以以“边车模式”运行,它本质上是一个Java应用程序,具有处理注册的嵌入式eureka客户端和心跳。对于Eureka客户端支持的所有操作,也会公开基于REST的接口。非Java客户端可以使用REST接口来查询有关其他服务的信息。

配置

With Eureka you can add or remove cluster nodes on the fly. You can tune the internal configurations from timeouts to thread pools. Eureka uses archaius and if you had a configuration source implementation a lot of these configurations can be tuned dynamically.

使用Eureka,您可以动态添加或删除群集节点。您可以将内部配置从超时调整到线程池。Eureka使用archaius,如果你有一个配置源实现,很多这些配置可以动态调整。

弹性设计

Being in the AWS cloud, it is hard to not think about resiliency in everything we build. Eureka benefits from this experience we gained, with the resiliency built into both the client and the servers.

Eureka clients are built to handle the failure of one or more Eureka servers. Since Eureka clients have the registry cache information in them, they can operate reasonably well, even when all of the eureka servers go down.

Eureka Servers are resilient to other eureka peers going down. Even during a network partition between the clients and servers, the servers have built-in resiliency to prevent a large scale outage.

在AWS云中,必须考虑我们构建的所有内容的弹性伸缩。Eureka受益于我们获得的这种体验,其中弹性内置于客户端和服务器中。Eureka客户端旨在处理一台或多台Eureka服务器的故障。由于Eureka客户端中包含注册表缓存信息,因此即使所有eureka服务器都出现故障,它们也可以运行得相当好。Eureka服务器可以抵御其他同类产品。即使在客户端和服务器之间的网络分区期间,服务器也具有内置的弹性以防止大规模中断。

分区集群

Deploying Eureka in multiple AWS regions is a fairly straightforward task. Eureka clusters between regions do not communicate with one another.

在多个AWS区域部署Eureka是一项相当简单的任务。区域之间的Eureka群集不会彼此通信。

监控

Eureka uses servo to track a lot information in both the client and the server for performance, monitoring and alerting.The data is typically available in the JMX registry and can be exported to Amazon Cloud Watch.

Eureka使用servo来跟踪客户端和服务器中的相关信息,以进行性能,监控和警报。数据通常在JMX注册表中提供,并可导出到Amazon Cloud Watch。

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值