Basic framework choice for microservice architecture: Spring Cloud or Dubbo?

In recent times, regardless of whether the Internet or traditional industries, almost all circles involving the field of information technology are discussing   . Recently, I have seen that major technical communities have begun to organize some salons and forums to share the relevant implementation experience of Spring  Cloud. For me, who is currently sorting out the content and example applications of Spring Cloud related suites, there is still a lot of motivation.微服务架构

At present, Spring Cloud is not well-known in China. In the process of job hunting a while ago, when communicating with architects, technical VPs or CTOs of some Internet companies, some did not even know the existence of the project. Perhaps this is also related to the domestic Alibaba open source service governance framework Dubbo. In addition to Dubbo's own relatively complete Chinese documents, many technology companies have architects from the Ali department. Therefore, as far as the current situation is concerned, domestic Dubbo is still the short term. world.

So when implementing a microservices architecture for the first time, which base framework should we choose?

The following content is the author's personal opinion, and the knowledge is limited. If it is wrong, it is completely normal. If you don't like it, don't spray it.

Round 1: Background

Dubbo is the core framework of Alibaba's service-oriented governance, and is widely used in various member sites of Alibaba Group. Alibaba's contributions to the open source community in recent years are remarkable both at home and abroad. For example, JStorm donated to Apache and joined the Apache Foundation, which has won the face of Chinese Internet people and made Alibaba in the eyes of Chinese people. It has been upgraded from an e-commerce company to a technology company.

Spring Cloud, we can know from the name, it is the product of Spring Source, the strong endorsement of the Spring community can be said to be the most influential organization in the Java enterprise world, in addition to Spring Source, Pivotal and Netfix are its powerful The backing and technical output. Among them, the whole set of microservice architecture suite open sourced by Netflix is ​​the core of Spring Cloud.

Summary: If you compare Dubbo with the Netflix suite, the former has more influence in China and the latter has more influence abroad. I think it can be a tie in the background; but if you want to compare it with Spring Cloud, because Spring Source In terms of endorsement, Spring Cloud is slightly better. However, the hero does not ask the source, and in terms of background, it cannot be used as the main factor in choosing a framework. When you are at a loss, it can be used as a reference.

Round 2: Community Activity

We choose an open source framework, and the activity of the community is a key point that we pay great attention to. The more active the community is, the faster the problem is solved, and the framework will be more and more perfect. Otherwise, when we encounter a problem, we have to solve it ourselves. For the team, it means that we have to maintain the source code of the framework ourselves, which will also be a great burden for the team.

Let's take a look at the update time of these two projects on github. The screenshots below are from July 30, 2016:

Last updated: May 6, 2016

Last updated: 12 minutes ago

It can be seen that Dubbo's update has been a few months ago, and the update frequency is very low. The update of Spring Cloud was 12 minutes ago, and it is still in the stage of high-speed iteration.

Summary: In terms of community activity, Spring Cloud is undoubtedly better than Dubbo. For teams that do not have a lot of energy and financial resources to maintain this part of open source content, Spring Cloud will be a better choice.

Round 3: Architectural Integrity

Perhaps many people will say that the comparison between Spring Cloud and Dubbo is a bit unfair. Dubbo only implements service governance, and there are 17 sub-projects (may be added) under Spring Cloud that cover all aspects of the microservice architecture. Service governance is only For one thing, Dubbo is, to a certain extent, just a subset of Spring Cloud Netflix. However, in the selection of the framework, the completeness of the scheme is precisely a content that needs to be paid attention to.

According to Martin Fowler  's description of the microservice architecture  , although the architecture has many advantages such as modular decoupling, independent deployment, and technical diversity compared with the monolithic architecture, due to decoupling in a distributed environment, it also brings A lot of testing and operational complexity.

Take a look at what support both Spring Cloud and Dubbo provide, depending on the elements of the microservices architecture.

  Dubbo Spring Cloud
Service Registry Zookeeper Spring Cloud Netflix Eureka
Service call method RPC REST API
service gateway without Spring Cloud Netflix Zuul
breaker imperfect Spring Cloud Netflix Hystrix
Distributed configuration without Spring Cloud Config
service tracking without Spring Cloud Sleuth
message bus without Spring Cloud Bus
data flow without Spring Cloud Stream
batch tasks without Spring Cloud Task
…… …… ……

Some of the core components are listed above, and it is generally understandable why Dubbo is just a subset similar to Netflix. Of course, it needs to be stated here that Dubbo does not mean that the components summarized as "none" in the above table cannot be implemented, but the Dubbo framework itself does not provide it, and needs to be integrated to achieve the corresponding functions, such as:

  • Distributed configuration: You can use Taobao's diamond and Baidu's disconf to achieve distributed configuration management. However, in addition to providing configuration management, the Config component in Spring Cloud, because its storage can use git, it naturally implements version management of configuration content and can be perfectly integrated with application version management.
  • Service tracking: You can use the open source Hydra of JD.com
  • Batch tasks: You can use Dangdang's open source Elastic-Job
  • ……

Although Dubbo itself only implements the foundation of service governance, and other features to ensure cluster security, maintainability, and testability are not well implemented, but almost most of the key components can be implemented by third-party open source. Mainly from the open source products of various large domestic Internet companies.

RPC vs REST

另外,由于Dubbo是基础框架,其实现的内容对于我们实施微服务架构是否合理,也需要我们根据自身需求去考虑是否要修改,比如Dubbo的服务调用是通过RPC实现的,但是如果仔细拜读过Martin Fowler的 microservices 一文,其定义的服务间通信是HTTP协议的REST API。那么这两种有何区别呢?

先来说说,使用Dubbo的RPC来实现服务间调用的一些痛点:

  • 服务提供方与调用方接口依赖方式太强:我们为每个微服务定义了各自的service抽象接口,并通过持续集成发布到私有仓库中,调用方应用对微服务提供的抽象接口存在强依赖关系,因此不论开发、测试、集成环境都需要严格的管理版本依赖,才不会出现服务方与调用方的不一致导致应用无法编译成功等一系列问题,以及这也会直接影响本地开发的环境要求,往往一个依赖很多服务的上层应用,每天都要更新很多代码并install之后才能进行后续的开发。若没有严格的版本管理制度或开发一些自动化工具,这样的依赖关系会成为开发团队的一大噩梦。而REST接口相比RPC更为轻量化,服务提供方和调用方的依赖只是依靠一纸契约,不存在代码级别的强依赖,当然REST接口也有痛点,因为接口定义过轻,很容易导致定义文档与实际实现不一致导致服务集成时的问题,但是该问题很好解决,只需要通过每个服务整合swagger,让每个服务的代码与文档一体化,就能解决。所以在分布式环境下,REST方式的服务依赖要比RPC方式的依赖更为灵活。
  • 服务对平台敏感,难以简单复用:通常我们在提供对外服务时,都会以REST的方式提供出去,这样可以实现跨平台的特点,任何一个语言的调用方都可以根据接口定义来实现。那么在Dubbo中我们要提供REST接口时,不得不实现一层代理,用来将RPC接口转换成REST接口进行对外发布。若我们每个服务本身就以REST接口方式存在,当要对外提供服务时,主要在API网关中配置映射关系和权限控制就可实现服务的复用了。

相信这些痛点也是为什么当当网在dubbox(基于Dubbo的开源扩展)中增加了对REST支持的原因之一。

小结:Dubbo实现了服务治理的基础,但是要完成一个完备的微服务架构,还需要在各环节去扩展和完善以保证集群的健康,以减轻开发、测试以及运维各个环节上增加出来的压力,这样才能让各环节人员真正的专注于业务逻辑。而Spring Cloud依然发扬了Spring Source整合一切的作风,以标准化的姿态将一些微服务架构的成熟产品与框架揉为一体,并继承了Spring Boot简单配置、快速开发、轻松部署的特点,让原本复杂的架构工作变得相对容易上手一些(如果您读过我之前关于Spring Cloud的一些核心组件使用的文章,应该能体会这些让人兴奋而激动的特性,传送门)。所以,如果选择Dubbo请务必在各个环节做好整套解决方案的准备,不然很可能随着服务数量的增长,整个团队都将疲于应付各种架构上不足引起的困难。而如果选择Spring Cloud,相对来说每个环节都已经有了对应的组件支持,可能有些也不一定能满足你所有的需求,但是其活跃的社区与高速的迭代进度也会是你可以依靠的强大后盾。

Round 4:文档质量

Dubbo的 文档 可以说在国内开源框架中算是一流的,非常全,并且讲解的也非常深入,由于版本已经稳定不再更新,所以也不太会出现不一致的情况,另外提供了中文与英文两种版本,对于国内开发者来说,阅读起来更加容易上手,这也是dubbo在国内更火一些的原因吧。

Due to the integration of a large number of components in Spring Cloud, the document volume is naturally much larger than that of dubbo. The content of the document is relatively concise and clear, but it is more inclined to integration. For more in-depth use, you need to check the detailed documentation of its integrated components. . In addition, because Spring Cloud is based on Spring Boot, many examples are much simpler than traditional Spring applications (because of automatic configuration, many contents have become the agreed default configuration), which may be a little uncomfortable for new developers. Understand and learn Spring Boot before using Spring Cloud, otherwise there may be a lot of ignorance.

Summary: Although Spring Cloud has a large amount of documentation, if you use Dubbo to integrate other third-party components, you actually have to read a lot of third-party component documentation, so I don’t think there is much difference in the amount of documentation. For document quality, due to the rapid iteration of Spring Cloud, there will inevitably be inconsistencies, so I think Dubbo is better in terms of quality. As for the document language, Dubbo naturally has more advantages for domestic development teams.

Summarize

Through the analysis of the above several links, I believe that everyone has a preliminary understanding of Dubbo and Spring Cloud. As far as my personal experience and understanding of these two frameworks are concerned, I can use an inappropriate analogy: the microservice architecture built with Dubbo is like assembling a computer. We have a high degree of freedom of choice in each link, but the final result is likely to be caused by If the quality of a memory is not good, it will not light up, which always makes people feel uneasy, but if you are a master, then these are not problems; and Spring Cloud is like a brand machine. Under the integration of Spring Source, a lot of work has been done. The compatibility test ensures that the machine has higher stability, but if you want to use something other than the original component, you need to have a sufficient understanding of its foundation.

Judging from the current attention and activity of Spring Cloud, it is very likely that it will become the standard framework for microservice architecture in the future. Therefore, I will continue to write the series of articles on Spring Cloud. Friends are also welcome to communicate and make progress together.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326308428&siteId=291194637