Microservice Spring Cloud Tutorial - What is Spring Cloud

Spring Cloud is a microservice framework based on Spring Boot. Spring Cloud originates from the Spring community, and is mainly provided by Pivotal and Netflix for technical iteration and maintenance.

With the popularity of microservices, major Internet companies at home and abroad have successively shared their solutions and open source frameworks for various problems in different scenarios in the microservice architecture.

  • Service governance : Alibaba's open-source Dubbo, Dangdang's expanded DubboX, Netflix's Eureka, and Apache's Consul, etc.
  • Distributed configuration management : Baidu's Disconf, Netflix's Archaius, 360's QConf, Ctrip's Apollo, and Spring Cloud's Config, etc.
  • Batch tasks : Dangdang's Elastic-Job, LinkedIn's Azkaban, and Spring Cloud's Task, etc.
  • Service tracking : JD.com's Hydra, Spring Cloud's Sleuth, and Twitter's Zipkin, etc.
  • ……

The above microservice frameworks or solutions all have the following two characteristics:

  • For the same microservice problem, Internet companies have different solutions.
  • A microservice framework or solution can only solve one or several problems in microservices, but it can't do anything about other problems.

In this case, to build a micro-distributed micro-service system, we need to choose from many solutions to these problems, which makes us have to spend a lot of energy on preliminary research, analysis, and experiments.

Spring Cloud is known as the "family bucket" for building distributed microservice systems. It is not a certain technology, but an ordered collection of a series of microservice solutions or frameworks. It integrates mature and proven microservice frameworks on the market, and repackages them through the idea of ​​Spring Boot, shielding and adjusting the complex configuration and implementation principles, and finally provides developers with a set of simple, easy-to-understand and easy-to-deploy And an easy-to-maintain distributed system development kit.

Spring Cloud includes nearly 20 sub-projects such as spring-cloud-config and spring-cloud-bus, providing service governance, service gateway, intelligent routing, load balancing, circuit breaker, monitoring and tracking, distributed message queue, configuration management, etc. field solutions.

Spring Cloud is not an out-of-the-box framework, it is a microservice specification with the following two generations of implementation:

  • First generation implementation: Spring Cloud Netflix 
  • Second-generation implementation: Spring Cloud Alibaba 

The Spring Cloud we introduce here refers specifically to the first-generation implementation of Spring Cloud.

Spring Cloud Common Components

Spring Cloud includes nearly 20 service components such as Spring Cloud Gateway, Spring Cloud Config, and Spring Cloud Bus. These components provide service governance, service gateway, intelligent routing, load balancing, fuses, monitoring and tracking, distributed message queues, and configuration management solutions in other fields.

Common components of Spring Cloud are shown in the table below.

Spring Cloud components describe
Spring Cloud Netflix Eureka The service governance component in Spring Cloud Netflix includes the implementation of service registry, service registration and discovery mechanism.
Spring Cloud Netflix Ribbon Service invocation and client load balancing components in Spring Cloud Netflix.
Spring Cloud Netflix Hystrix Known as "Brother Porcupine", the fault-tolerant management component of Spring Cloud Netflix provides strong fault tolerance for delays and failures in the service.
Spring Cloud Netflix Feign A declarative service call component based on Ribbon and Hystrix.
Spring Cloud Netflix Zuul The gateway component in Spring Cloud Netflix provides functions such as intelligent routing and access filtering.
Spring Cloud Gateway A gateway framework developed based on technologies such as Spring 5.0, Spring Boot 2.0, and Project Reactor. It uses the Filter chain to provide the basic functions of the gateway, such as security, monitoring/indicators, and current limiting.
Spring Cloud Config Spring Cloud's configuration management tool supports the use of Git to store configuration content, realizes external storage of application configuration, and supports operations such as refreshing, encrypting, and decrypting configuration on the client side.
Spring Cloud Bus The event and message bus of Spring Cloud is mainly used to propagate events or state changes in the cluster to trigger subsequent processing, such as dynamic refresh configuration.
Spring Cloud Stream The message middleware component of Spring Cloud integrates message middleware such as Apache Kafka and RabbitMQ, and perfectly realizes the isolation between the application and the message middleware by defining the binder as the middle layer. By exposing a unified Channel channel to the application, the application can easily send and receive messages without having to consider various message middleware implementations.
Spring Cloud Sleuth Spring Cloud distributed link tracking component can perfectly integrate Twitter's Zipkin.

Note: Netflix is ​​an online video website in the United States. It is recognized as an outstanding practitioner of large-scale production-level microservices and a leader in the microservices industry. Netflix's open source components have been proven in production for many years in its large-scale distributed microservice environment, and are mature and reliable.

The difference and connection between Spring Boot and Spring Cloud

Both Spring Boot and Spring Cloud are members of the Spring family. They both play very important roles in microservice development. There are differences and connections between the two.

1. The division of labor between Spring Boot and Spring Cloud is different

Spring Boot is a Spring-based rapid development framework, which can help developers build Web projects quickly. In microservice development, Spring Boot focuses on developing a single microservice quickly and easily.

Spring Cloud is a one-stop solution under the microservice architecture. Spring Cloud focuses on the coordination and governance of global microservices. In other words, Spring Cloud is equivalent to the big steward of microservices. It is responsible for managing the microservices developed by Spring Boot and providing them with configuration management, service discovery, circuit breakers, routing, micro-agents, event buses, and decision-making campaigns. And services such as distributed sessions.

2. Spring Cloud is implemented based on Spring Boot

Spring Cloud is implemented based on Spring Boot. Similar to Spring Boot, Spring Cloud also provides a series of Starters, which are the products of Spring Cloud's repackaging of various microservice frameworks using Spring Boot ideas. They shield the complex configuration and implementation principles in these microservice frameworks, enabling developers to quickly and easily use Spring Cloud to build a distributed microservice system.

3. Spring Boot and Spring Cloud have different number of dependencies

Spring Boot is a lightweight framework that requires less dependencies to build Spring Boot projects.

Spring Cloud is a collection of a series of microservice framework technologies, each of which requires an independent dependency (Starter POM), so building a complete set of Spring Cloud projects often requires a large number of dependencies.

4. Spring Cloud cannot run independently of Spring Boot

Spring Boot can directly create projects or modules that can run independently without Spring Cloud.

Spring Cloud is implemented based on Spring Boot. It cannot create projects or modules independently, let alone run independently from Spring Boot.

Note: Although Spring Boot can be used to develop a single microservice, it does not have the ability to manage and coordinate microservices, so it can only be regarded as a rapid development framework for microservices, not a microservice framework.

Spring Cloud version

Spring Cloud contains many sub-projects (components), which are independently updated and iterated, and each maintains its own release version number.

In order to avoid confusion between the version number of Spring Cloud and the version number of its sub-projects, Spring Cloud does not use the common digital version number, but defines the version information in the following way.

{version.name} .{version.number}

The version information of Spring Cloud is as follows:

  •  version.name : The version name, which is named after the station name of the London subway station in the United Kingdom, and corresponds to the release sequence of Spring Cloud versions in alphabetical order (ie from A to Z). For example, the first version is Angel, and the second version is Angel. The first version is Brixton (British place name), followed by Camden, Dalston, Edgware, Finchley, Greenwich, Hoxton and so on.
  • version.number : version number, each version of Spring Cloud will release a "service releases" version, referred to as SRX version, when the update content of each version has accumulated to a certain level or has a major BUG fix, where X is an increasing number , for example Hoxton.SR8 means the 8th Release version of Hoxton.

Spring Cloud version selection

When using Spring Boot + Spring Cloud for microservice development, we need to determine the Spring Cloud version according to the version of Spring Boot in the project, otherwise many unexpected errors will occur.

The version correspondence between Spring Boot and Spring Cloud is as follows (refer toSpring Cloud official website ).

Spring Cloud Spring Boot
2020.0.x (Ilford) 2.4.x, 2.5.x (starting from Spring Cloud 2020.0.3)
Hoxton 2.2.x, 2.3.x (starting from Spring Cloud SR5) 
Greenwich 2.1.x
Finchley 2.0.x
Edgware 1.5.x
Dalston 1.5.x

Note: Spring Cloud has officially stopped updating the versions of Dalston, Edgware, Finchley and Greenwich.

In addition to the version correspondence shown in the above table, we can also use a browser to access  https://start.spring.io/actuator/info to obtain the version correspondence between Spring Cloud and Spring Boot (JSON version).

{
   ……
    "bom-ranges":{
        ……
        "spring-cloud":{
            "Hoxton.SR12":"Spring Boot >=2.2.0.RELEASE and <2.4.0.M1",
            "2020.0.4":"Spring Boot >=2.4.0.M1 and <2.5.6-SNAPSHOT",
            "2020.0.5-SNAPSHOT":"Spring Boot >=2.5.6-SNAPSHOT and <2.6.0-M1",
            "2021.0.0-M1":"Spring Boot >=2.6.0.M1 and <2.6.0-SNAPSHOT",
            "2021.0.0-SNAPSHOT":"Spring Boot >=2.6.0-SNAPSHOT"
        },
        ……
    },
 ……
}

SpringCloud+RabbitMQ+Docker+Redis+Search+Distributed, system detailed springcloud microservice technology stack course

Guess you like

Origin blog.csdn.net/Itmastergo/article/details/131931929