

Introduction
PolarisMesh is Tencent's open-source million-level service discovery and governance center, which has accumulated Tencent's experience in distributed service governance from the virtual machine to the container era. As a core component in the distributed and microservice architecture, PolarisMesh provides a series of capabilities such as service addressing, traffic scheduling, fault tolerance, and access control. It can be used indiscriminately in K8s and virtual machine environments, supports mainstream development models, and is compatible with Open source ecosystems such as grpc, spring cloud, and servicemesh help users quickly build business architectures with strong scalability and high availability, and realize the transformation from traditional architectures to cloud-native architectures.

What is Eureka
Eureka is a Java language-based service discovery framework open sourced by Netflix. The first version was released in 2014. Now the version of Spring Cloud Neflix combined with Spring Cloud is widely used in the industry.
The main function of Eureka is to provide service registration and discovery for cross-process RPC calls between applications and the function of fault instance elimination. Its working principle is shown in the following figure:

-
Eureka Server: Provides service data management, service discovery, abnormal node removal and other capabilities based on eventual consistency. -
Provider: The called party of the service, which registers itself with the Eureka server when it starts up, sends a heartbeat renewal request periodically during the running process to keep it alive, and deregisters itself from the Eureka server when the process ends. -
Consumer: The service caller, based on the Eureka service discovery interface, pulls the service list from eureka, and selects an IP address to make a remote call to the callee according to a certain load balancing algorithm.
Eureka Server itself supports clustered deployment, and synchronizes data through push-pull combination to achieve eventual consistency.
-
Push mode : When a single Eureka Server receives a write request, it will asynchronously replicate the write request to other Eureka servers in the cluster. 拉模式:Eureka Server本身也是作为Eureka客户端,会往集群里面的其他Eureka server注册及反注册自身,定时续约并拉取服务列表更新缓存数据。

相关链接:
spring-cloud-netflix-eureka-client:
https://github.com/spring-cloud/spring-cloud-netflix/tree/main/spring-cloud-netflix-eureka-client

Eureka存在的问题
大部分开发者在使用Eureka时都会遇到这样或那样的问题,我们通过收集社区以及用户的反馈,归纳总结为以下3类常见的问题:
1. 性能问题
从上文的描述可知,Eureka各个server之间是通过异步请求的方式进行写请求的同步,写请求包括注册/反注册/心跳续约的请求,同步失败会进行重试。这种异步同步模式,在客户端集群规模较大、或者网络情况不好触发了重试风暴的情况下,容易因为处理过多的同步续约请求,导致server端高负载。
下面是当时某个客户的一个现网场景,4个Eureka server,跨区进行高可用部署,客户端数有2000+,其中一个区的Eureka server出现网络异常,导致续约的同步请求都重试到其他区的服务端,导致服务端高负载,出现大量请求超时,超时情况下会继续重试,从而导致高负载问题蔓延到其他区。
下图是当时的一个监控截图,在1小时内,服务端平均负载飙升到80%,续约请求的时延也出现10s的峰值,导致大量服务健康状态出现异常,严重影响了现网的服务运营质量。

2. 运维复杂度高
下图是Eureka的运维控制台,大部分用户反馈该控制台在实际使用过程中存在以下问题,从而影响了运维效率:

-
不支持根据实例或者服务的某些信息数据进行搜索。 -
服 务实际上是与部分、业务相关的,而Eureka这里并不支持在控制台这些数据的录入或修改,使得对服务数据的运维管理不太友好。 -
Eureka Server本身支持通过接口的方式对实例进行手动隔离(OUT_OF_SERVICE),但是Eureka控制台没法进行操作。
3. Eureka 2.x版本社区停止更新
在2018年,Eureka社区发了通告,停止对Eureka 2.0的开源更新工作,对于使用Eureka的现网业务来说,增加了运维风险和成本。


北极星兼容Eureka
1. 无缝迁移
北极星是腾讯开源的服务发现和治理组件,在服务注册发现基础上,提供了流量调度,故障剔除等治理能力,其功能可完整覆盖Eureka的使用场景。同时北极星提供了存算分离的架构,以及全功能的服务治理控制台。在性能和可运维性上相比Eureka都有不少的提升。
-
用户程序变更问题:用户当前程序已经集成了Eureka的客户端,如果切换成北极星客户端的话,需要做代码变更,成本较高。 -
数据迁移问题:用户现网已经注册到Eureka上的存量数据,如何平滑迁移到北极星上,过程中不能出现业务的中断。
针对问题一:北极星在新版本1.5.0实现了Eureka Server API的全兼容,做到支持各个语言、不同版本的Eureka Client进行直接接入。
北极星服务端基于一套开放的服务治理模型来实现各个治理功能,在API层,提供了插件化的机制来进行其他服务模型的对接转换。为满足Eureka的兼容性需求,只需要在API层实现一个对接插件即可完成:

针对问题二:北极星在服务端通过服务数据单向同步,以及关联查询的方式,实现了新老服务的互访,用户可以按自己的节奏将服务从Eureka注册中心迁移到北极星。

2. 迁移后效果
用户将服务数据迁移到北极星后,可以解决上文描述的使用的Eureka Server所碰到的3个问题:
(1)性能数据

通过监控曲线可以看到,北极星(Eureka)的整体CPU使用情况稳定在2.29核,并且整体的CPU利用率稳定在57%左右(5W注册实例,并发进行全量数据拉取及实时心跳续约)

并且,当实例规模从1w到5w中,CPU的利用率都是稳定速率增加的,没有出现说CPU利用率陡然增加,整体的内存利用了也没有出现大幅度的变动。
在注册规模进一步提升时,由于北极星设计之初就是存算彻底分离的架构设计,因此当北极星出现高负载时,可以快速的对北极星进行水平扩容。
(2)可运维性

从控制台的易用性来看,北极星控制台经过腾讯内部的多次打磨,在易用性上对用户更容易上手,且可支持多种的查询条件方便进行各种服务信息的检索。同时北极星本身带有全功能的服务治理能力,可以服务设置服务治理规则,实现包含Eureka客户端在内的多种框架的统一服务治理。
(3)社区活跃度
北极星开源社区当前由腾讯主导维护,正常每月发布1个迭代版本,每双周会进行开发者例会的技术分享,BUG问题在社区提问后,不超过1周时间会得到回复及修复。详情可了解:https://github.com/polarismesh

如何使用
获取1.5.0版本:
https://github.com/polarismesh/polaris/releases/tag/v1.5.0
安装并快速使用北极星:
https://polarismesh.cn/zh/doc/快速入门/使用框架接入.html#使用框架接入
使用兼容Eureka功能(点击文末 阅读原文 可跳转至详情页面):
https://polarismesh.cn/zh/doc/使用指南/存量兼容/兼容eureka客户端.html#兼容eureka客户端

文末福利
新春佳节即将来临,中间件小Q妹为大家特别准备了 2000份 新春红包封面,祝大家新春快乐,虎年大吉!
领取方式:关注「腾讯云中间件」公众号,回复关键词 『红包』 即可获取,随机发放,数量有限,先到先得哦~
往期
推荐
《Message deduplication 这里的去重与你想的可能不一样|Apache Pulsar 技术系列》
《倒计时3天!Apache Pulsar 社区年度盛会——Pulsar Summit Asia 重磅来袭!》
《腾讯云消息队列TDMQ RabbitMQ 版开启公测,文末有惊喜!》
《全面拥抱Go社区:PolarisMesh全功能对接gRPC-Go | PolarisMesh12月月报》
《SpringBoot应用优雅接入北极星PolarisMesh》
《腾讯云CKafka重磅上线DataHub,让数据流转更简便》
《ZooKeeper系列文章:ZooKeeper 源码和实践揭秘(三)》
《Serverless可观测性的价值》
《喜报|CKafka荣获可信云消息队列服务稳定性先进级认证》
《RoP重磅发布0.2.0版本:架构全新升级,消息准确性达100%》

扫描下方二维码关注本公众号,
了解更多微服务、消息队列的相关信息!
解锁超多鹅厂周边!



点个在看你最好看
本文分享自微信公众号 - 腾讯云中间件(gh_6ea1bc2dd5fd)。
如有侵权,请联系 [email protected] 删除。
本文参与“OSC源创计划”,欢迎正在阅读的你也加入,一起分享。