Microservice architecture and the past and present of Spring Cloud

Reprinted Disclaimer: The source of the article is to carry sacks of teenager

Contents of this article:


Write at the beginning

  Before learning Spring Cloud, if you don't know much about microservice architecture, let's first understand what it is 微服务架构.

1. What is microservice architecture

  In March 2014, Martin Fowler proposed a new architecture system "微服务架构".
  Martin Fowler (Picture from : https://martinfowler.com/aboutMe.html )

  Microservice architecture is an architectural pattern. It advocates 将单一应用程序划分成一组小的服务mutual coordination and configuration between services to provide users with ultimate value. 每个服务运行在器独立的进程中Employed between the service and the service 轻量级的通信机制interoperable (typically based Restful API HTTP protocol). Each service around the specific business to build, and 能够被独立的部署到生产环境、类生产环境so on. In addition, a unified and centralized service management mechanism should be avoided as much as possible. For a specific service, appropriate languages ​​and tools should be selected according to the business context to build it.

2. Introduction to Spring Cloud

  Now that we have understood the microservice architecture system, let's take a look at Spring Cloud. First of all, let me remind you: Our first impression must not regard Spring Cloud as a technology or framework.

  Spring Cloud 其实是一系列框架的有序集合. It uses facilitate the development of Spring Boot cleverly simplify the development of distributed systems infrastructure, such as 服务发现注册, 配置中心, 消息总线, 负载均衡, 断路器, 数据监控, etc., can be done with Spring Boot style of development a key to start and deploy .

  Spring Cloud 并没有重复制造轮子,它只是将各家公司开发的比较成熟、经得起实际考验的服务框架组合起来,通过Spring Boot 风格进行再封装屏蔽掉了复杂的配置和实现原理,最终给开发者留出了一套简单易懂、易部署和易维护的分布式系统开发工具包。(Conceptual text from Baidu Encyclopedia: the Spring Cloud )

  We can understand it like this: Spring Cloud = 分布式微服务架构的一站式解决方案,是多种微服务架构落地技术的集合体,俗称微服务全家桶。First, let's post a picture to introduce some components
Insert picture description here
  in the microservice architecture system: before Spring Cloud, if we want to develop a microservice architecture project. In terms of framework usage, we need to manually select. For example:

Features Frame/component selection
Service call Ribbon
Service fusing Central
Service message Rocket MQ
Automated build deployment Docker/Jenkins
… And others …And others

  After choosing the framework framework, because these frameworks are products developed by different companies. In the process of use, it is inevitable that you will often encounter 版本兼容性and 多个框架之间的协调性other problems. Obviously this is a very difficult problem, and sometimes we have no way to deal with the bugs we encounter. Such a bad experience, it sucks.

  他来了,他来了,Spring 带着 微服务全家桶 Spring Cloud 向我们走来了. At this point, we no longer need to choose one by one, we only need a Spring Cloud to do it all, which is obviously a great boon for our programming world.

3. What are the quality projects of Spring Cloud integration

  Spring Cloud since such a cow, we need to have more 组件/框架in the back for technical support, and compatibility, coordination aspects should have a good combination. Let's take a look at how many (21) technologies are integrated in this large collection of Spring Cloud : (Picture from: Spring Cloud Chinese Net-Official Document Chinese Version )
Insert picture description here

4.Dubbo vs. Spring Cloud

  Spring Cloud has become the mainstream technology stack for microservice development, and it is also very popular in the domestic developer community. Although Dubbo can also do microservices. Dubbo was open sourced in 2012, more than 8 years ago. During the development of Dubbo, Ali once gave up the maintenance of Dubbo. For some reasons, he later donated it to Apache .

   The Dubbo framework is old. Now Spring Cloud Alibabait has been officially added to the Spring Cloudfamily. And Spring Cloud is the latest technology that will definitely be more favored than Dubbo.

  In the next development, we recommend that you use Spring Cloud 2.x + Spring Cloud Alibaba for microservice projects. (According to the company's needs, you can also use Dubbo to do it. In terms of technology, use the new instead of the old, haha)

Spring Cloud Dubbo
Service registration discovery Eureka, zk, consul zk
Service call method rest way rpc
Service monitoring spring boot admin dubbo monitor
Fuse downgrade Hystrix/Sentinel Imperfect (Mock)
Service gateway Zuul/Gateway no
Distributed Configuration Center Config/nacos no
Message bus Bus no
MQ message data flow Stream no

5. Do you have to learn so many frameworks in the Spring Cloud system?

  In the picture introduced earlier, we can see that there are 21 technologies integrated in the large collection of Spring Cloud, so do we need to learn so many technologies/frameworks? ? (With a dumb face, big head...)

  With so many technologies, obviously we don’t need to learn them all. According to the usage of large factories, we only need to learn a part of it, the technology/framework corresponding to each service. As shown in the figure below:
Insert picture description here
   But the good times are not long and will be accompanied 2018 年 Eureka 2.0 版本的闭源,开源版本停止更新. (Eureka is from Netflix). After that, on and off a lot of the technology has changed / stopped more / upgrade . 几乎全套都停更了!!!. As a result, Spring Cloud became difficult for a while.

  The above described in the figure are still mainstream technologies until February 2020. Along with various technologies 停更引发的"惨案", Spring Cloud was forced to choose other technologies instead.

6. Spring Cloud upgraded alternatives

  With the suspension of various technologies in the Spring Cloud system 几乎全套都停更了, Spring Cloud was forced to choose other technologies to replace the upgrade. The upgraded technical architecture of Spring Cloud is shown in the following figure:
Insert picture description here

  • Service registry: recommended Spring Cloud Alibaba Nacos, not Consul (if the company does not want to use new technology, you can also use ZK as the service registry)
  • Service call: Ribbon is used. But this little friend also has a little problem. He is a half-baked gadget and has also entered a state of maintenance. Spring 官方还在继续用,但是后续会推出一个 Spring Cloud LoadBalancer ,它会慢慢取代 Ribbon(Official note: Ribbon can continue to be used, but the update is stopped.) (In a funny saying: Ribbon stop is a mild patient, Eureka is in the ICU and has died.)
  • Service call 2: Feign, who is as famous as Ribbon, almost died. This buddy hasn't been updated for a long time, and the Spring community can't afford to wait, so they have a new one OpenFeign. (Feign can no longer be used, it's dead, it is recommended to use OpenFeign in 2020)
  • Downgrade Service: Service downgraded the field comes porcupine brother Hystrix up. But Brother Porcupine is dead . The official website is no longer recommended. But in China, Hystrix Porcupine is a set of service downgrade and fuse framework that comes with Spring Cloud, which is still in large-scale use. After Hystrix is ​​stopped, foreigners recommend it resilience4j, but in China, we still recommend Spring Cloud Alibaba's Sentinel (strongly recommended, better than Hystrix)
  • Service gateway:, Zuul also belongs to Netflix. 它就有点搞笑了,内部开发团队产生分裂,自己把自己作死了。The Netflex company backstage wanted to produce another Zuul2 by itself, but failed to develop it. At this time, Spring has developed a new service gateway by itself gateway, which is currently the recommended mainstream gateway service component.
  • Service Spring Cloud ConfigConfiguration: . It is no longer used. Now the mainstream recommendation: .1.携程网的 apolo 2. 强烈推荐使用 Spring Cloud Alibaba Nacos(强烈推荐)
  • Bus service: the Spring Cloud native, using Bus, now slowly being Spring Cloud Alibaba Nacosreplaced.

The related content of microservice architecture and Spring Cloud will be introduced first.

Next article: Version selection between Spring Boot and Spring Cloud

Guess you like

Origin blog.csdn.net/m0_37989980/article/details/108392166