Spring Cloud 2020.0.0 is officially released, what does it mean for developers?

header image.png

Author | YourBatman Senior Architect in Online Education, Spring Framework Open Source Contributor Leng Leng Yunji Architect, Open Source Project Pig Leader, Spring Cloud Alibaba Committer Source | Alibaba Cloud Native Official Account

In the middle of the night on December 22, 2020, Beijing time, the Spring Cloud 2020.0.0 version was officially released. 2020.0.0 is the first named Spring Cloud release to use the new version naming scheme. Aside from the more developer-friendly naming conventions that are visible to the naked eye, this release completely ditches the Netflix technology stack and is a long-maintained major release. What does this mean for developers? Today, we invite YourBatman and Spring Cloud Alibaba committer, who are active authors in the open source community, to explain the important changes in this release, and more importantly, talk to you about how we as developers should deal with it in the future .

Spring Cloud version management

Before the official release of Spring Cloud 2020.0.0, the name of Spring Cloud's Release Train was named after the name of the London subway station and arranged in alphabetical order, such as: Hoxton, Greenwich, Ilford, etc. There are two such naming methods. Fatal problem:

  • It is very unfriendly to non-English- speaking countries, such as China, and cannot quickly clarify the relationship between version numbers

  • There are only 26 English letters. What if the version number is after Z? How to continue to develop?

1.png

Spring Cloud  supports major releases for three years under  the Pivotal OSS support policy . In addition, after a major or minor version of Spring Cloud is released, if there are serious bugs and security issues, it will be maintained for an additional period of time (ranging from 6-12 months). Refer to the following table:

2.jpg

3.jpg

Interpretation of core changes

As a major version , Spring Cloud 2020.0.0 has brought many notable changes, among which some blocking updates (not backward compatible) are the biggest highlights of this article, come and serve.

Core Change 1: Goodbye, Netflix

As early as 2018, Spring Cloud announced in its Roadmap some libraries/versions that will be terminated , the most important of which is that the Spring Cloud Netflix project enters maintenance mode , and then plans to be completely removed in 2020.

Spring Cloud's decision to make such a decision is not necessarily proactive. We know that Spring Cloud has always used the  Netflix OSS suite as its official default one-stop solution, and the Netflix OSS suite at that time could not wait to be equal to Spring Cloud. Netflix announced that its core components Hystrix, Ribbon, Zuul, Archaius, etc. have entered a maintenance state around 2018 .

Today, Spring Cloud 2020.0 has been officially released, and in this major version, we have finally made a move according to the established plan  spring-cloud-netflix . I drew you  spring-cloud-netflix-dependencies a comparison chart of the main differences between the previous and previous versions of the xml file, which is clear at a glance:

4.jpg

  • The old version  spring-cloud-netflix-dependencies manages all components of Netflix, including Hystrix, Ribbon, Zuul, Eureka, etc. And since the 2020.0 version, it has and only manages Eureka (including Server and Client).

Core Change 2: Continue to formulate industry standards and improve abstract definitions

For most Spring Cloud application developers,  spring-cloud-commons modules are probably unfamiliar. As the core of the Spring Cloud technology stack, this module provides a unified abstraction for the most important service registration and discovery, load balancing, and context management of the entire solution. spring cloud alibaba Wait until the whole family bucket is  spring-cloud-commons realized. This version makes related jumps to the default startup text of the context launcher and the core code of the load balancer.

spring-cloud-commons
  ├── actuator
  ├── circuitbreaker
  ├── discovery
  ├── hypermedia
  ├── loadbalancer
  └── serviceregistry

Core Change 3: Strongly push the reactive asynchronous system

reactor is an implementation framework for reactive ( reactive programming ) and the work of the Pivotal team.

Both Spring Cloud Gateway and Spring Cloud Loadbalancer are built on reactor programming.

5.png

In addition, Spring's official evangelist Josh Long recently published a book "Reactive Spring". If you want to know more about reactor, you may wish to read it in depth.

Core Change 4: Better Embrace Cloud Native Capabilities

Spring Cloud 2020 is built on Spring Boot 2.4, and has a stronger configuration file processing mechanism that can be very well adapted to cloud-native (for example, kubernetes' configMap can be directly applied) configuration; built-in Docker image construction and hierarchical analysis and optimization capabilities.

If the team is using kubernetes, it would  spring-cloud-kubernetes also be a good alternative to Netflix.

6.jpg

Component Alternatives

Since Spring Cloud has cut the Netflix suite drastically, there must be an alternative. That's for sure, and the Spring Cloud team recommends alternative components for us:

7.jpg

Spring Cloud LoadBalancer

Of the above alternatives, you may be the most unfamiliar and most curious is  that it was only a small project in the Spring Cloud LoadbalancerSpring Cloud incubator , and it was stranded for a time. After restarting and developing, it has now made its great mission officially used to completely replace Ribbon and become the only implementation of Spring Cloud load balancer .

8.png

As shown in the figure, the load balancing abstract  LoadBalancerClient interface has two implementations, and after the Spring Cloud 2020.0 version, it BlockingLoadBalancerClient is the only implementation.

Spring Cloud LoadBalancer currently only supports round-robin load balancing strategies, which is too simple compared to Ribbon's multiple high-availability strategies.

Spring Cloud Circuit Breaker

Circuit Breaker provides an abstraction compatible with multiple circuit breaker component implementations, allowing developers to choose the most familiar circuit breaker component for business development.

9.png

Here we mainly introduce Sentinel and Resilience4j. Sentinel is an important component of Spring Cloud Alibaba. By introducing  spring-cloud-starter-alibaba-sentinel   , it can have the capabilities of circuit breaker, downgrade, flow control, etc., and provide a graphical console. As a similar component, Resilience4j is based on A functionally designed lightweight fault-tolerant library that provides capabilities such as fusing, current limiting, and isolation. However, the officially provided spring-cloud-starter-circuitbreaker-resilience4j plug-in has limited capabilities and cannot be managed directly using the console (if monitoring requires additional Micrometer service).

Spring Cloud Alibaba adaptation

  • Due to the dependence on Ribbon components, the latest Spring Cloud Alibaba 2.2.3 is not fully compatible with Spring Cloud 2020, and only needs to be fine-tuned.
// 排除 Ribbon (当然也可以排查 maven 依赖)
@EnableAutoConfiguration(excludeName = 
"org.springframework.cloud.netflix.ribbon.RibbonAutoConfiguration")
  • Add spring cloud loadbalancer dependency.
<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>
  • Services involved in loading the configuration center need to start bootstrap (default disabled in 2020).
<!--增加此依赖即可完成启动-->
<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>
  • For the above adjustments, please refer to the Compatible Adapted Spring Cloud 2020 example .

How developers face and embrace change

As mentioned above, Spring Cloud provides powerful encapsulation and abstraction capabilities. For example, it  spring-cloud-circuit-breaker provides the encapsulation of common fault-tolerant components, and does not need to consider  @hystrixcommand``@SentinelResource component native annotations during use.

public static class DemoControllerService {
    private RestTemplate rest;
    private CircuitBreakerFactory cbFactory;
    public String slow() {
        return cbFactory.create("slow").run(() -> rest.getForObject("/slow", String.class), throwable -> "fallback");
    }
}
  • Changes in components implemented through such abstract bottom layers have little impact on users who use Spring Cloud family buckets at the upper layer (for example, "Spring Cloud Alibaba Migration Guide: Zero-Code Migration from Eureka to Nacos").

  • About learning The spring-cloud-commnsauthor does not recommend reading the source code directly (part of the reactor code is easy to persuade to quit), and it is recommended to debug it in the form of a specific implementation of DEBUG (for example NacosDiscoveryClient), the core code is only a hundred lines.

10.png

  • Therefore, for developers, whether it is before Netflixor choosing a Alibabatechnology stack, the core is to grasp the spring-cloud-commonsabstraction , and it is particularly important to grasp the Spring Cloud standard.

Summarize

Spring Cloud 2020.0.0 is the main version of Spring Cloud. It is a very important existence, and the upgrades and changes are also huge. In particular, it is reflected in the complete removal of Netflix modules, the change in the way Spring Cloud is started, and so on. With the release of Spring Boot 2.4.x and Spring Cloud 2020.0, and the abandonment of the Netflix OSS suite, a new in- depth programming experience will surely be entered, full of surprises and expectations.

Of course, we still highly recommend everyone to use the Spring Cloud Alibaba family bucket. At present, Spring Cloud Alibaba has been open sourced for two years and has graduated from the official website. Not only is it eye-catching in terms of attention and activity, but also through the release of the Activist Lab start.aliyun.com Provide sandbox and Java project scaffolding , Arthas code diagnosis tool , etc. to become the most complete Spring Cloud implementation of the tool chain.

11.png

Data source: http://www.gharchive.org/ GitHub developer behavior data activity calculation formula for the past two years: https://github.com/X-lab2017/github-analysis-report-2019/blob/master/ REPORT.md

Recommended reading

Recommended activities

12.png

For the first Spring Cloud Alibaba Meetup City Station in 2021, we invited Ji Min, head of the Alibaba middleware distributed transaction team, Fang Jian, author of "In-depth Understanding of Spring Cloud and Actual Combat", Fang Yincheng, Apache Dubbo PMC, and Ren Haojun, founder of Nepxion open source community. , Tong Zilong, middleware architect of a well-known Internet company, and Jiang Zhi, technical manager of Qiniu Cloud, chatted about the development trend of Go language and Spring ecology together, and shared in-depth microservices of well-known Internet education companies! Click here to register to participate~

{{o.name}}
{{m.name}}

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=324098123&siteId=291194637