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

Source:

http://blog.didispace.com/microservice-framework/

 

In recent times, regardless of the Internet or traditional industries, almost all circles involved in the field of information technology are discussing microservice architecture . 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. This is still a lot of motivation for me, who is sorting out the content and example applications of Spring Cloud related suites recently.

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 that 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, there are also Pivotal and Netfix. 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.

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

In addition, since Dubbo is a basic framework, whether the content of its implementation is reasonable for us to implement the micro-service architecture, we also need to consider whether to modify it according to our own needs. For example, Dubbo's service calls are implemented through RPC, but if you read Martin carefully Fowler's microservices article, which defines the inter-service communication is the REST API of the HTTP protocol. So what's the difference between the two?

First, let's talk about some pain points of using Dubbo's RPC to implement calls between services:

  • The interface between the service provider and the caller is too dependent: We define their own service abstract interface for each microservice and publish it to the private repository through continuous integration. The caller application has a strong dependency on the abstract interface provided by the microservice. , so regardless of the development, testing, and integration environments, it is necessary to strictly manage version dependencies, so that there will not be a series of problems such as the inconsistency between the server and the caller that causes the application to fail to compile successfully, and this will also directly affect the environment requirements for local development. Often an upper-layer application that relies on many services needs to update a lot of code every day and install it before subsequent development can be carried out. Without a strict version management system or the development of some automation tools, such dependencies can become a nightmare for the development team. The REST interface is more lightweight than RPC. The dependency between the service provider and the caller only relies on a contract, and there is no strong dependency at the code level. Of course, the REST interface also has pain points, because the interface definition is too light, which can easily lead to definition documents. The inconsistency with the actual implementation leads to the problem of service integration, but this problem is easy to solve. It only needs to integrate swagger through each service and integrate the code and documentation of each service to solve it. Therefore, in a distributed environment, REST-based service dependencies are more flexible than RPC-based dependencies.
  • Services are platform-sensitive and difficult to reuse: Usually, when we provide external services, we provide them in the form of REST, which can achieve cross-platform features, and callers of any language can implement it according to the interface definition. So when we want to provide a REST interface in Dubbo, we have to implement a layer of proxy to convert the RPC interface into a REST interface for external publishing. If each of our services exists in the form of a REST interface, when we want to provide services to the outside world, we can mainly configure the mapping relationship and permission control in the API gateway to realize the reuse of services.

I believe that these pain points are also one of the reasons why Dangdang has added support for REST in dubbox (an open source extension based on Dubbo).

Summary : Dubbo realizes the foundation of service governance, but to complete a complete microservice architecture, it needs to be expanded and improved in each link to ensure the health of the cluster, so as to reduce the pressure of development, testing and operation and maintenance. , so that the personnel in each link can really focus on the business logic. Spring Cloud still promotes Spring Source's style of integrating everything, integrates some mature products and frameworks of microservice architectures in a standardized manner, and inherits the characteristics of Spring Boot's simple configuration, rapid development, and easy deployment, making the original complex Architectural work becomes relatively easy to get started with (if you have read my previous article on the use of some of the core components of Spring Cloud, you should be able to appreciate these exciting and exciting features, portal ). Therefore, if you choose Dubbo, please be sure to prepare a complete set of solutions in each link, otherwise it is very likely that with the increase of the number of services, the entire team will be tired of dealing with the difficulties caused by various architectural deficiencies. If you choose Spring Cloud, relatively speaking, each link already has corresponding component support, and some may not meet all your needs, but its active community and high-speed iteration progress will also be you can rely on Strong backing.

Round 4: Document Quality

Dubbo's documentation can be said to be first-class among domestic open source frameworks, very complete, and explained in depth. Since the version has been stabilized and will not be updated, it is unlikely that there will be inconsistencies. In addition, Chinese and English are provided. Version, for domestic developers, it is easier to read and get started, which is why dubbo is more popular in China.

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=326418327&siteId=291194637