eureka历险(一)

eureka官方文档

eureka简介
What is 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的服务, 主要用于服务定位,实现了负载均衡(load balancing)容错(failover)
  • eureka 客户端: 有一个内嵌的负载均衡器,基于循环负载
  • 在 netflix的实现中,提供了一个更复杂的负载均衡器,比如根据流量,资源使用情况,错误条件等,提供了更好的弹性.

由此可见,我们需要的关注点是: load balancing 和 failover

What is the need for 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.

How different is Eureka from 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.


  • 与基于代理的负载均很方式比较一
    client 端实例可以获取到所有的我们想要调用的server实例,这个是福是祸呢?
    eureka没有提供开箱即用的解决方案,但是它可以是无状态的,无状态也就意味着提供了更好的可伸缩性.

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.


  • 与基于代理的负载均很方式比较二
    eureka可以让应用程序恢复负载均衡器的中断,可用的servers信息会被缓存在客户端,这需要少量的内存,但是有了会更好的弹性

How different is Eureka from 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.


  • eureka的region隔离
    Eureka类似于内部DNS,与世界各地的DNS服务器无关。Eureka也是区域隔离的,因为它不知道其他AWS区域中的服务器。它保存信息的主要目的是在一个区域内实现负载平衡。

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).

How is Eureka used at 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.


  • 用于red/black deployments

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


  • 用于cassandra deployments

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.


  • 用于由于各种其他原因携带其他特定于应用程序的关于服务的其他附加元数据。

When should I use 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.

How does the application client and application server communicate?
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.

High level architecture
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.


  • eureka服务发现
    服务在Eureka注册,然后每30秒发送一次心跳来续签租约。如果客户机不能多次续订租约,则在大约90秒内将其从服务器注册表中取出。注册信息和更新被复制到集群中的所有eureka节点。来自任何区域的客户端都可以查找注册表信息(每30秒发生一次)来定位他们的服务(可能在任何区域)并进行远程调用。

Non-Java services and clients
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.

Configurability
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,如果您有一个配置源实现,那么很多配置都可以动态调优。

Resilience
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.

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


  • 多个regions
    区域之间的Eureka集群彼此之间不通信。

Monitoring
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。

要点总结:

  1. 什么是eureka?
    eureka 基于rest的服务, 主要用于服务定位,实现了负载均衡(load balancing)容错(failover)

  2. eureka与传统的代理负载均衡器区别?
    最主要的区别是,它的服务路由是放在客户端实现的,客户端知道所有的servers信息, 好处是无状态的,具有更好的伸缩性.

  3. 在真实使用时,服务注册,发现大概过程是什么样?

    服务在Eureka注册,然后每30秒发送一次心跳来续签租约。如果客户机不能多次续订租约,则在大约90秒内将其从服务器注册表中取出。注册信息和更新被复制到集群中的所有eureka节点。来自任何区域的客户端都可以查找注册表信息(每30秒发生一次)来定位他们的服务(可能在任何区域)并进行远程调用。

  4. Regions概念? todo
    大概是根据地域分机器组群的意思,这样能更快的找到服务.
    这个我感觉是值得关注一下–留坑

第一次写博客,大家多多指教.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值