How to choose microservice technology?

This article was first published from "MOOC". If you want to know more about IT dry goods and hot news in the programmer circle, welcome to pay attention to "MOOC"!

Author: Chen Yujiji | MOOC Lecturer


With the popularity of microservices in recent years, in daily work or technical exchanges, we can always hear which companies say that they have refactored their projects with microservices. Yes, microservices can indeed solve single systems. The problem of becoming bloated and difficult to maintain. Now if your enterprise is considering using microservices to restructure the architecture, then the enterprise must choose a framework to implement microservices.

We all know that there are two popular frameworks in the microservice market, one is Ali's Dubbo and the other is SpringCloud. Which of the two is better has always been a headache. Next, let's discuss how to select the technology of microservices.

1. Factors considered in technology selection

In fact, we can not consider whether to use Dubbo or SpringCloud, but return to the technology selection itself, first look at the indicators that may exist in the technology selection, and then consider which microservice framework to choose based on these indicators.

considerations judge
background Investigate the background of the selection technology and understand the source
Whether it meets the business needs Whether it can meet the needs of the business, remember to avoid excessive references, technology is to support the business, and avoid being too ahead of the business
cost The cost includes labor cost, time cost, and resource hardware cost
Is it open source If it is open source, you should know which organization is the open source, and use the community version with caution
Community activity Community activity determines software quality to a certain extent. When you encounter a problem, the active community has already been encountered by others and may have been solved very well.
safety Know if a framework or component is vulnerable
Is it consistent with the company's technology stack Try to consider technologies that are consistent or irrelevant with the company's technology stack to ensure quality and cost
Is it a technology you are familiar with Do not use too many unknown new technologies in one selection to avoid too many uncontrollable risks and ensure stability
stability Whether the system is open source and running for a long time, whether it has stood the test
Scalability Is it compatible with other platforms, and whether it can be used for secondary development
performance efficiency Consider throughput, response time, etc.
The pace of technological advancement The cycle of the selected technology must be significantly longer than the life cycle of the project to ensure that the technology itself is iterated closely with time

It can be seen that there are still many indicators that need to be evaluated for technology selection, and it is also a decision that requires experience. It takes a lot of research and input to make a decision that suits your own situation based on the existing business situation.

When we do technology selection, the most taboo thing is to cram for the first time, randomly search for several comparative articles on the Internet, and use these fragmented information to make decisions. We must make sure that our selection is based on the judgment of current business growth, and we must also understand the assumptions behind the business facts.

Even so, it may not be possible to select an optimal solution, but through this series of evaluation criteria, it is absolutely possible to select a technology stack that meets the current business.

2. Dubbo or SprigCloud

2.1 Dubbo

Dubbo, a high-performance and excellent service framework open-sourced by Alibaba, currently supports tens of thousands of applications in Ali distributed applications supported by Dubbo, runs on more than 200,000 server instances, and calls trillions of levels every day. The highest distributed application cluster. At present, Dubbo has been donated by Ali to the Apache Foundation as a top-level project.

In fact, Dubbo has also experienced a period of ups and downs, and there was a large period of no maintenance in the middle, which may have given way to Alibaba Cloud's charging project HSF. However, it has been re-maintained under the apache top-level project, and the latest version is 3.0.

2.2 SpringCloud

SpringCloud is a product of Spring Source. The strong endorsement of the Spring community can be said to be an unrivaled organization in the Java business world. SpringBoot and SpringCloud are seamlessly connected. In the early stages of SpringCloud's development, Netfix provided it with powerful technology. Output, the Netflix switch suite is basically the heart of Spring Cloud at the very beginning. However, as some components of Netflix are not updated, SpringCloud has provided alternative or even stronger solutions in various aspects.

If we only compare the backgrounds of the two, the former has greater influence in China, while the latter has greater influence in foreign and domestic emerging companies. However, due to the strong backing of Spring Source, in the background, Spring Cloud should be slightly better. However, it should not be used as the main basis for the selection framework.

2.3 Community Activity

In 2017, before Dubbo joined the Apache top-level project, someone compared the activity of the two frameworks on github. It can be seen that SpringCloud is active in hours, while Dubbo is basically based on years.

But today, after Dubbo joined the apache top-level project, he re-compared on github, and it can be seen that the gap is narrowing

Of course, the real activity is not so simple to make a judgment, but a rough observation can still draw the conclusion that Dubbo's activity in the community, especially in China, has resumed. When there is no official maintenance, there are still some companies that have further developed and maintained Dubbo, such as Dubbox, a distributed framework developed by Dangdang based on Dubbo.

2.4 Performance of both

Dubbo and SpringCloud are actually just the framework of the solution. The difference in centralized performance is mainly reflected in the service call and transmission protocol. Dubbo uses the RPC communication protocol, which provides serialization of Dubbo. The default protocol of Dubbo uses a single long link and NIO asynchronous Communication (keep connection, rotation training processing), using custom messages, is suitable for small quantity and large concurrent service call scenarios,
and SpringCloud uses the REST API of the HTTP protocol by default.

Someone on the Internet deliberately made a simulation test to test the performance of the two, using a Pojo object containing 10 attributes, requesting 100,000 times, Dubbo and SpringCloud under different numbers of threads, time-consuming per request (ms)

The above pictures and test results are taken from the Internet

Not surprisingly, SpringCloud using HTTP is indeed inferior to Dubbo using RPC. But this resulted in: Http + Json's Rest communication, which is difficult to reuse in terms of performance, is actually a misunderstanding.

A greater degree of performance evaluation is to determine whether the communication of the Http protocol will become a real bottleneck point for the load of the application.

On most corporate networks, network consumption isn't much of a problem. If there is a real problem, SpringCloud is not a mandatory binding of Http + Json, you can also choose high-performance RPC such as Thrift and Protobuf, and serialization as an alternative.

2.5 Architectural Integrity

The above points are at most one of the reference points in this selection. What really decides the choice is the integrity of the architecture, which determines whether it meets our needs.

In fact, it is unfair to compare SpringCloud and Dubbo in terms of architectural integrity. Dubbo only implements service governance, while SpringCloud has more than 30 projects on github so far, covering all aspects of the microservice architecture. To a certain extent, Dubbo refers to a subset of SpringCloud, but when it comes to choosing a framework, the completeness of the solution is exactly what we need to focus on the most.

In the above chapters, as mentioned, although microservices bring the benefits of clear division of modules, independent deployment, and multiple styles of technology, they also bring a lot of complexity due to distribution. These complexities need to be managed and necessary components for support.

Dubbo SpringCloud
Service Registry Zookeeper Netflix Eureka / Consult / Nacos
Service calls are always RPC REST API
service gateway none NetFlix Zuul / gateway
breaker imperfect NetFlix Hystrix
distributed configuration none SpringCloud Config
link tracking none SpringCloud Sleuth
message bus none SpringCloud Bus
batch task none SpringCloud Task

Some commonly used core components are listed above. From the table, it is not difficult to find why Dubbo is only a subset of SpringCloud. However, one thing must be stated. The "None" in the comparison item in Dubbo does not mean that it cannot be implemented, but the default Dubbo framework itself Not provided, and we can still find many matching open source components on the market.

For example:

  • Service gateway: Nginx+lua can be used as the basic gateway, which can play the rules of simple gateways such as authentication and routing;
  • Circuit breaker: Ali's Sentinel can be used, Sentinel is more powerful than Hystrix and has a console;
  • Distributed configuration: Baidu's Disconf or Ctrip's Apollo can be used as distributed configuration management. Compared with SpringCloud's Config, Config is stored and configured on git. Using the default configuration is not intuitive enough, and both Disconf and Apollo provide excellent The console has grayscale publishing, and the authority isolation function is more powerful;
  • Link tracking: SkyWalking can be used, and SkyWalking has also been incorporated into the top project of apache. It has developed rapidly in the past two years. Compared with Zipkin, Cat is more powerful, let alone Sleuth;
  • Message bus: RabbitMq can be used, and RabbitMq using the AMQP protocol can also implement a message agent to connect distributed system nodes in series to reach the broadcast state;
  • Batch tasks: xxl-job can be used.

You can think of Dubbo as an assembled computer, and SpringCloud as a branded computer. The following is a comparison between our assembled Dubbo and SpringCloud, in which most of the components selected for assembly are from domestic:

Dubbo + optional components SpringCloud
Service Registry Zookeeper Netflix Eureka / Consult / Nacos
Service calls are always RPC REST API
service gateway Nginx + Second NetFlix Zuul / gateway
breaker Sentinel NetFlix Hystrix
distributed configuration Apollo SpringCloud Config
link tracking Skywalking SpringCloud Sleuth
message bus RabbitMq SpringCloud Bus
batch task Xxl-Job SpringCloud Task

Dubbo has a high degree of freedom of choice in all aspects. It can also be said that it can only be selected externally. But after all, it is an external option. For example, if we choose a memory or a hard disk for an assembled computer, there is a problem and the whole computer crashes. If you are a master of DIY, these are not a problem, but if you are a novice, or not very familiar with each component, then the brand opportunity may be more suitable for you.

SpringCloud is like a brand machine. Under the integration of Spring Source, a lot of compatibility tests have been done to ensure the high stability of the machine. However, there are also some components that are not easy to use in the default components of SpringCloud.

In addition to the difference between the components we talked about above, there are some small details, such as

In the early years, the author used Dubbo to implement implicit parameter passing, and changed the source code of Dubbo (because dubbo stopped maintenance earlier, so partial secondary development was carried out). When using SpringCloud, I found that it can be realized by directly implementing RequestInterceptor. Maybe SpingCloud is a late launch, so it is more thoughtful in some details, and it is more suitable for Xiaobai's use.

2.6 Learning and Recruitment Costs

It should be said that the learning cost of SpringCloud is lower than that of Dubbo. Various components are basically out of the box, and relying on the SpringSource tree, compatibility and reliability are guaranteed. I believe that no one who writes Java code People are not familiar with Spring. In terms of coding, relying on SpringBoot, various component configurations can be used, which greatly reduces the cost of learning and entry.

3. Summary

The relevant concepts and comparisons between Dubbo and SpringCloud have been clearly described above. As for whether to choose Dubbo or SpringCloud, it depends on your own situation and needs, and there is no recommended choice here.

The author has always used Dubbo before, but later went to a new company and a new team, and chose the ali version of SpringCloud. The reason for consideration is that the new team still lacks relevant experience in this area, and SpringCloud provides complete component support. , SpringCloud is a relatively safe choice.

As a rising star, SpringCloud is simple and convenient to use, and SpringCloud also has strong community support, and the documentation is also very complete. The new team does not need to invest too much time here to read scattered documents and research various open source components. Time is on business.

Moreover, the company also has other technology stack teams, and there is a need for interface intermodulation. The RPC used by Dubbo by default cannot implement cross-language well, while SpringCloud's default Http REST itself supports cross-language implementation.


Welcome to pay attention to the "MOOC" account, we will always insist on providing high-quality content in the IT circle, sharing dry knowledge, let's grow together!

This article was originally published on Muke.com, please indicate the source for reprinting, thank you for your cooperation

Guess you like

Origin blog.csdn.net/mukewangguanfang/article/details/130404334