Spring Cloud到底是解决什么问题的

Spring Cloud到底是解决什么问题的

前言

从 Spring Boot 到 Spring Cloud 或者 K8s ,通过 Spring Boot 我们实现了 Spring 开发的配置自动化、集成第三方组件的配置自动化、以及内嵌Web容器,大大地简化了我们开发应用程序时所需的配置和部署工作。

那么 Spring Cloud 又为我们解决了什么问题呢?为什么会出现?是在什么场景下以及给谁用的?

概述

Spring Cloud 是一系列框架的有序集合。它利用 Spring Boot 的开发便利性,巧妙地简化了分布式系统基础设施的开发流程。例如,服务发现/注册、配置中心、消息总线、负载均衡、断路器、数据监控等功能,都可以用 Spring Boot 的开发风格做到一键部署和启动。

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

Spring Cloud 不同于其它 Spring 的优秀项目,它不再是一个基础框架类,而是一个更高层次的、架构视角的综合性大型项目,其目标旨在构建一套标准化的微服务解决方案让架构师、开发者在使用微服务理念构建应用系统的时候,面对各个环节的问题都可以找到相应的组件来处理

Spring Cloud 可以说是 Spring 社区为微服务架构提供了一个“全家桶”套餐。由于“套餐”中的组件通过一个社区进行包装与整合,使得“套餐”中各个组件之间的配合变得更加和谐,这可以有效减少我们在组件的选型和整合上花费的精力,所以它可以帮助我们快速构建起基础的微服务架构系统

Spring Cloud 是对微服务架构提供了巨大支持和强有力的技术后盾。它是一个解决微服务架构实施的综合性解决框架,它整合了诸多被广泛实践和证明过的框架作为实施的基础部件,又在该体系基础上创建了一些非常优秀的边缘组件。

使用 Spring Cloud 实施微服务架构就像直接购买品牌机一样,在 Spring 社区的整合之下,做了大量的兼容性测试,保证了其拥有更好的稳定性。

总结:Spring Cloud 是一套标准的开发规范,是微服务架构的“一篮子”解决方案。

为什么会出现?

何时采用微服务架构?

企业业务发展早期一般采用单块架构,但是随着业务和团队规模的不断扩张,原来单块架构逐渐成为阻碍业务规模化和快速创新的瓶颈

当企业的业务复杂性和团队规模到达一个点,那么单块应用由于耦合等因素,生产率会急剧下滑,这个时候就需要考虑拆分成微服务

采用微服务架构,因为微服务需要基础设施这些额外的技术支持,企业就需要额外的投入去搞这些微服务基建。

所以,大部分企业都经历过一个拆分结构的过程,不断地将其应用服务按照业务领域或者团队边界进行拆分,以适应业务和团队不断扩张的需求。而且这个结构拆分的过程会一直持续演进下去。随着业务的不断发展和扩张,也随着对业务领域的不断深入理解再逐步拆分,就演化出微服务架构

来源:《系统架构设计时到底要不要采用微服务架构?》https://mp.weixin.qq.com/s/8VPZFRqUrXyO-X7rIZ2Spw


微服务公共关注点

微服务最终的目标是实现业务价值,交付业务价值,但是为了让开发人员能够专注于业务交付,微服务需要底层基础设施的支撑,这些基础设施也称为微服务的公共关注点(common concerns)

6.微服务公共关注点

如果把微服务的上述这些关注点,把它们抽象封装和沉淀下,最终产生的软件产品就是微服务开发框架

Spring Cloud 正是在应对大规模微服务开发带来的挑战时,演进沉淀并且开源贡献给社区的解决方案。

来源:《技术栈选型之微服务公共关注点及Dubbo、Spring Cloud和K8s横向比对》https://mp.weixin.qq.com/s/yA9RZRD4gSE1tbWyg-JCJg

官方材料

Overview

Spring Cloud provides tools for developers to quickly build some of the common patterns in distributed systems (e.g. configuration management, service discovery, circuit breakers, intelligent routing, micro-proxy, control bus, one-time tokens, global locks, leadership election, distributed sessions, cluster state). Coordination of distributed systems leads to boiler plate patterns, and using Spring Cloud developers can quickly stand up services and applications that implement those patterns. They will work well in any distributed environment, including the developer’s own laptop, bare metal data centres, and managed platforms such as Cloud Foundry.

来源:https://spring.io/projects/spring-cloud

Spring Cloud为开发人员提供了用于快速构建分布式系统中某些常见模式的工具(例如,配置管理,服务发现,断路器,智能路由,微代理,控制总线)

分布式系统的协调产生了样板模式,并且使用 Spring Cloud 的开发人员可以快速支持实现这些模式的服务和应用程序。

它们可以在任何分布式环境中正常工作,包括开发人员自己的笔记本电脑,裸机数据中心和受管理的平台,例如Cloud Foundry。

Spring Cloud 是一个基于 Spring Boot 实现的微服务架构开发工具。它为微服务架构中涉及的配置管理、服务治理、断路器、智能路由、微代理、控制总线、全局锁、决策竞选、分布式会话和集群状态管理等提供了一种简单的开发方式。


Features

Spring Cloud focuses on providing good out of box experience for typical use cases and extensibility mechanism to cover others.

Spring Cloud 专注于为典型的用例和扩展机制提供良好的开箱即用体验,以涵盖其他情况。

  • Distributed/versioned configuration(分布式/版本化配置)
  • Service registration and discovery(服务注册和发现)
  • Routing(路由)
  • Service-to-service calls(服务间的调用)
  • Load balancing(负载均衡)
  • Circuit Breakers(断路器)
  • Global locks(全局锁)
  • Leadership election and cluster state(选主及集群状态)
  • Distributed messaging(分布式消息传递)

Main Projects

Spring Cloud 包含了很多子项目。

  • Spring Cloud Config(分布式/版本化配置)
  • Spring Cloud Netflix
    • 服务发现(Eureka)
    • 断路器(Hystrix)
    • 智能路由(Zuul)
    • 客户端负载平衡(Ribbon)
  • Spring Cloud Gateway(路由)
  • Spring Cloud OpenFeign(服务间的调用)
  • Spring Cloud Sleuth(调用链跟踪)
  • Spring Cloud Bus(分布式消息传递)
  • Spring Cloud Alibaba
    • Sentinel(流量管理)
    • Nacos(配置管理、服务注册和发现)
    • Spring Cloud Stream RocketMQ(分布式消息传递)
    • Seata(分布式事务)
    • Apache Dubbo RPC (服务间的调用)

Spring Cloud Config

Centralized external configuration management backed by a git repository. The configuration resources map directly to Spring Environment but could be used by non-Spring applications if desired.

Spring Cloud Config provides server and client-side support for externalized configuration in a distributed system. With the Config Server you have a central place to manage external properties for applications across all environments. The concepts on both client and server map identically to the Spring Environment and PropertySource abstractions, so they fit very well with Spring applications, but can be used with any application running in any language. As an application moves through the deployment pipeline from dev to test and into production you can manage the configuration between those environments and be certain that applications have everything they need to run when they migrate. The default implementation of the server storage backend uses git so it easily supports labelled versions of configuration environments, as well as being accessible to a wide range of tooling for managing the content. It is easy to add alternative implementations and plug them in with Spring configuration.

来源:https://spring.io/projects/spring-cloud-config

Spring Cloud Config 配置管理工具,支持使用 git 存储配置内容,可以使用它实现应用配置的外部化存储,并支持客户端配置信息刷新、加密/解密配置内容等。

由 git 支持的集中式外部配置管理。配置资源直接映射到 Spring 环境,但如果需要,也可以提供给非 Spring 应用程序使用。

Spring Cloud Config 为分布式系统中的外部化配置提供服务器端和客户端支持

使用 Config Server,您可以在集中式管理所有环境中应用程序的外部属性

客户端和服务器上的概念都与 Spring Environment 和 PropertySource 抽象映射相同,因此它们非常适合 Spring 应用程序,但可以与以任何语言运行的任何应用程序一起使用。

在应用程序从开发人员到测试人员再到生产人员的整个部署过程中,您可以管理这些环境之间的配置,并确保应用程序具有它们迁移时所需的一切。

服务器存储后端的默认实现使用git,因此它轻松支持带标签的配置环境版本,并且可以通过各种工具来访问和管理这些内容。很容易添加替代实现并将其插入到Spring配置中。

Spring Cloud Config Server features:

  • HTTP, resource-based API for external configuration (name-value pairs, or equivalent YAML content)
  • Encrypt and decrypt property values (symmetric or asymmetric)
  • Embeddable easily in a Spring Boot application using @EnableConfigServer

Spring Cloud Config Client features (for Spring applications):

  • Bind to the Config Server and initialize Spring Environment with remote property sources
  • Encrypt and decrypt property values (symmetric or asymmetric)

Spring Cloud Config Server :

  • 为外部配置(名称-值对或等效的YAML内容)提供了一个基于HTTP资源的API。
  • 加密和解密属性值(对称或非对称)
  • 使用 @EnableConfigServer ,Spring Cloud Config Server 可以轻松嵌入到 Spring Boot 应用程序中。
@SpringBootApplication
@EnableConfigServer
public class ConfigServer {
  public static void main(String[] args) {
    SpringApplication.run(ConfigServer.class, args);
  }
}

Spring Cloud Config Client(用于 Spring 应用程序):

  • 绑定到配置服务器并使用远程属性源初始化 Spring 环境;
  • 加密和解密属性值(对称或非对称)。

Spring Cloud Netflix

Integration with various Netflix OSS components (Eureka, Hystrix, Zuul, Archaius, etc.).

Spring Cloud Netflix provides Netflix OSS integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms. With a few simple annotations you can quickly enable and configure the common patterns inside your application and build large distributed systems with battle-tested Netflix components. The patterns provided include Service Discovery (Eureka), Circuit Breaker (Hystrix), Intelligent Routing (Zuul) and Client Side Load Balancing (Ribbon)…

来源:https://spring.io/projects/spring-cloud-netflix

Spring Cloud Netflix 对多个 Netflix OSS 开源套件进行整合。

集成各种 Netflix OSS 组件(Eureka, Hystrix, Zuul, Archaius, etc.)。

该项目通过自动配置并绑定到 Spring 环境和其他 Spring 编程模型习惯用法,为Spring Boot 应用提供了 Netflix OSS 集成

通过使用一些简单的注解,您可以快速启用和配置应用程序内部的通用模式,并使用经过测试的 Netflix 组件构建大型分布式系统。提供的模式包括服务发现(Eureka),断路器(Hystrix),智能路由(Zuul)和客户端负载平衡(Ribbon)

Spring Cloud Netflix features:

Service Discovery: Eureka instances can be registered and clients can discover the instances using Spring-managed beans

Service Discovery: an embedded Eureka server can be created with declarative Java configuration

Circuit Breaker: Hystrix clients can be built with a simple annotation-driven method decorator

Circuit Breaker: embedded Hystrix dashboard with declarative Java configuration

Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations

Client Side Load Balancer: Ribbon

External Configuration: a bridge from the Spring Environment to Archaius (enables native configuration of Netflix components using Spring Boot conventions)

Router and Filter: automatic registration of Zuul filters, and a simple convention over configuration approach to reverse proxy creation

Eureka:服务治理组件,包含服务注册中心、服务注册与发现机制的实现。

服务发现是基于微服务的体系结构的主要宗旨之一。尝试手动配置每个客户端或某种形式的约定可能很困难并且很脆弱。

Eureka 是 Netflix Service Discovery 服务器和客户端。可以将服务器配置和部署为高可用性,每个服务器将有关已注册服务的状态复制到其他服务器。

当客户端向 Eureka 注册时,它会提供有关其自身的元数据-例如主机、端口、运行状况指示器URL、主页和其他详细信息。Eureka 从属于服务的每个实例接收心跳消息。如果心跳超出可配置的时间表,则通常会将实例从注册表中删除。

Hystrix:容错管理组件,实现断路器模式,帮助服务依赖中出现的延迟和为故障提供强大的容错能力。

Ribbon:客户端负载均衡的服务调用组件。

Feign:基于 Ribbon 和 Hystrix 的声明式服务调用组件。

Zuul:网关组件,提供智能路由、访问过滤等功能。


Spring Cloud Gateway

Spring Cloud Gateway is an intelligent and programmable router based on Project Reactor.

This project provides a library for building an API Gateway on top of Spring WebFlux. Spring Cloud Gateway aims to provide a simple, yet effective way to route to APIs and provide cross cutting concerns to them such as: security, monitoring/metrics, and resiliency.

Spring Cloud Gateway 提供了一种简单而有效的方式来对微服务的API进行路由。

Spring Cloud Gateway features:

  • Built on Spring Framework 5, Project Reactor and Spring Boot 2.0
  • Able to match routes on any request attribute.
  • Predicates and filters are specific to routes.
  • Circuit Breaker integration.
  • Spring Cloud DiscoveryClient integration
  • Easy to write Predicates and Filters
  • Request Rate Limiting
  • Path Rewriting

Spring Cloud OpenFeign

Spring Cloud OpenFeign provides integrations for Spring Boot apps through autoconfiguration and binding to the Spring Environment and other Spring programming model idioms.

Features

  • Declarative REST Client: Feign creates a dynamic implementation of an interface decorated with JAX-RS or Spring MVC annotations

Feign是Spring Cloud组件中一个轻量级RESTful的HTTP服务客户端,Feign内置了Ribbon,用来做客户端负载均衡,去调用服务注册中心的服务。Feign的使用方式是:使用Feign的注解定义接口,调用接口,就可以调用服务注册中心的服务。

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-feign</artifactId>
</dependency>

OpenFeign是Spring Cloud在Feign的基础上支持了SpringMVC的注解,如@RequestMapping等等。OpenFeign的@FeignClient可以解析SpringMVC的@RequestMapping注解下的接口,并通过动态代理的方式产生实现类。

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency>  

springcloud F 及F版本以上 springboot 2.0 以上基本上使用openfeign,openfeign 如果从框架结构上看就是2019年feign停更后出现版本,也可以说大多数新项目都用openfeign ,2018年以前的项目在使用feign

来源:springcloud feign 与 openFeign区别:https://www.jianshu.com/p/fc5de8218384


Spring Cloud Sleuth

Distributed tracing for Spring Cloud applications, compatible with Zipkin, HTrace and log-based (e.g. ELK) tracing.

Spring Cloud Sleuth provides Spring Boot auto-configuration for distributed tracing.

Spring Cloud 应用的分布式跟踪实现,可以完美整合 Zipkin.

Features

Sleuth configures everything you need to get started. This includes where trace data (spans) are reported to, how many traces to keep (sampling), if remote fields (baggage) are sent, and which libraries are traced.

Specifically, Spring Cloud Sleuth…

Adds trace and span ids to the Slf4J MDC, so you can extract all the logs from a given trace or span in a log aggregator.

Instruments common ingress and egress points from Spring applications (servlet filter, rest template, scheduled actions, message channels, feign client).

If spring-cloud-sleuth-zipkin is available then the app will generate and report Zipkin-compatible traces via HTTP. By default it sends them to a Zipkin collector service on localhost (port 9411). Configure the location of the service using spring.zipkin.baseUrl.


Spring Cloud Bus

An event bus for linking services and service instances together with distributed messaging. Useful for propagating state changes across a cluster (e.g. config change events).

Spring Cloud Bus links nodes of a distributed system with a lightweight message broker. This can then be used to broadcast state changes (e.g. configuration changes) or other management instructions. AMQP and Kafka broker implementations are included with the project. Alternatively, any Spring Cloud Stream binder found on the classpath will work out of the box as a transport.

事件、消息总线,用于传播集群中的状态变化或事件,以触发后续的处理,比如用来动态刷新配置等。


Spring Cloud Alibaba

Spring Cloud Alibaba provides a one-stop solution for distributed application development. It contains all the components required to develop distributed applications, making it easy for you to develop your applications using Spring Cloud.

With Spring Cloud Alibaba, you only need to add some annotations and a small amount of configurations to connect Spring Cloud applications to the distributed solutions of Alibaba, and build a distributed application system with Alibaba middleware.

Spring Cloud Alibaba 致力于提供微服务开发的一站式解决方案,它是 Spring Cloud 组件被植入 Alibaba 元素之后的产物。利用 Spring Cloud Alibaba,可以快速搭建微服务架构并完成技术升级。

Spring Cloud Alibaba 的主要功能:流量控制和服务降级,服务注册与发现,分布式配置,事件驱动,消息总线,分布式事务,Dubbo RPC 。

Features

Flow control and service degradation:flow control, circuit breaking and system adaptive protection with Alibaba Sentinel

Sentinel :以“流”为切入点,在流量控制、并发性、容错降级和负载保护等方面提供解决方案,以保护服务的稳定性。

Service registration and discovery:instances can be registered with Alibaba Nacos and clients can discover the instances using Spring-managed beans. Supports Ribbon, the client side load-balancer via Spring Cloud Netflix

Distributed Configuration:using Alibaba Nacos as a data store

Nacos:一个具备动态服务发现和分布式配置等功能的管理平台,主要用于构建云原生应用程序。

Event-driven:building highly scalable event-driven microservices connected with Spring Cloud Stream RocketMQ Binder

Message Bus: link nodes of a distributed system with Spring Cloud Bus RocketMQ

RocketMQ :一个高性能、高可用、高吞吐量的金融级消息中间件。Spring Cloud Alibaba 将 RocketMQ 定制化封装,开发人员可“开箱即用”。

Distributed Transaction:support for distributed transaction solution with high performance and ease of use with Seata

Seata:一个高性能且易于使用的分布式事务解决方案,可用微服务架构。

Dubbo RPC:extend the communication protocols of Spring Cloud service-to-service calls by Apache Dubbo RPC

Dubbo :一个基于Java 的高性能开源 RPC 框架。

Spring、Spring Boot、Spring Cloud 的关系

Spring :

  • Spring 框架为解决企业应用开发的复杂性而创建的框架,为开发 Java 应用程序提供了全面的基础架构支持。
  • 它提供了依赖注入和“开箱即用”的一些模块,如:Spring MVC、Spring JDBC、Spring AOP、Spring IoC、Spring ORM、Spring Test、Spring Security。这些模块大大地缩短了应用程序的开发时间,提高了开发应用程序的效率。

在 Spring 出现之前,如果要进行 Java Web 开发,则非常复杂,例如,若需要将记录插入数据库,则必须编写大量的代码来打开、操作和关闭数据库。而使用 Spring JDBC 模块的 JDBCTemplate,只需要进行数据库操作即可,打开和关闭交由 Spring 管理。

Spring Boot :

  • Spring Boot 是 Spring 框架的扩展和自动化,它消除了在 Spring 中需要进行的 XML(Extensible Markup Language) 文件配置,使得开发变得更快、更高效、更自动化。

Spring Cloud:

  • Spring Cloud 是一套分布式服务治理框架,它本身不提供具体功能性的操作,只专注于服务之间的通信、熔断和监控等。因此,需要很多组件来共同支持一套功能。
  • Spring Cloud 主要用于开发微服务。

微服务是可以独立部署、水平扩展、独立访问的服务单元。Spring Cloud 它提供了各种方案来维护整个生态。

三者的关系:

  • Spring Boot 要依赖 Spring 的,它是 Spring 的自动化。
  • Spring Cloud 通过依赖 Spring Boot 来构建微服务应用。

1.spring、SpringBoot和SpringCloud三者的关系

Spring Boot 专注于快速、方便的集成单个个体,而 Spring Cloud 专注于全局的服务治理。

Spring Cloud 与 Spring Boot 版本对应关系

Spring Cloud 是基于 Spring Boot 构建的,它们之间的版本有配套的对应关系。在构建项目时,要注意版本之间的这种对应关系,版本若对应不上则会出现问题。

Spring Cloud 与 Spring Boot 的版本配套关系

Spring CloudSpring Boot
Camden1.4.x
Dalston1.5.x
Edgware1.5.x
Finchley2.0.x
Greenwich2.1.x
Hoxton2.2.x

Spring Cloud 包含一系列子组件,如 Spring Cloud Config、Spring Cloud Netflix 等,为了防止与这些子组件的版本号混淆, Spring Cloud 的版本号全部使用英文单词形式命名。

具体来说,Spring Cloud 的版本号使用了英国伦敦地铁站的名称来命名,并按字母A~Z的次序发布版本,它的第一个版本叫作 Angel ,第二个版本叫作 Brixton ,以此类推。

另外每个大版本在解决了一个严重的 Bug 后,Spring Cloud 会发布一个 Service Release 版本(小版本),简称 SRX版本,其中 X 是顺序的编号,比如 Finchely.SR4 是 Finchely 大版本的第 4 个小版本。

Spring Cloud Hoxton 版本是基于 Spring Boot 2.2 构建的,Spring Boot 2.2 又是基于 Spring Framework 5.2 构建的,也就是说,这是一次整体的、全方位的大版本升级。

Spring Cloud Finchley 到 Greenwich 版本的升级其实很小,可以说微乎其微,主要是提升了对 Java 11 的兼容性。

官方查询版本对应关系:

https://spring.io/projects/spring-cloud#learn

1.官方获取Spring Cloud与Spring Boot版本匹配关系

https://docs.spring.io/spring-cloud/docs/Hoxton.SR12/reference/html/

2.官方获取Spring Cloud与Spring Boot版本匹配关系

Spring Cloud 与 Spring Boot 常用的版本实践:

  • Spring Cloud Finchley.SR4 + Spring Boot 2.0.8.RELEASE
  • Spring Cloud Greenwich.RELEASE + Spring Boot 2.1.2.RELEASE
  • Spring Cloud Greenwich.SR1 + Spring Boot 2.1.3.RELEASE
  • Spring Cloud Greenwich.SR2 + Spring Boot 2.1.8.RELEASE
  • Spring Cloud Greenwich.SR6 + Spring Boot 2.1.18.RELEASE
  • Spring Cloud Hoxton.SR9 + Spring Boot 2.3.7.RELEASE
  • Spring Cloud Hoxton.SR12 + Spring Boot 2.3.12.RELEASE

示例:

<properties>
    <spring.boot.version>2.1.2.RELEASE</spring.boot.version>
    <spring.cloud.version>Greenwich.RELEASE</spring.cloud.version>
</properties>

<dependencyManagement>
    <dependencies>
        <!-- Spring Boot -->
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-dependencies</artifactId>
            <version>${spring.boot.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
        <!-- Spring Cloud -->
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring.cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

总结

概述

  • Spring Cloud 是一系列框架的有序集合。它利用 Spring Boot 的开发便利性,巧妙地简化了分布式系统基础设施的开发流程。例如,服务发现/注册、配置中心、消息总线、负载均衡、断路器、数据监控等功能,都可以用 Spring Boot 的开发风格做到一键部署和启动。
  • Spring Cloud 它将各家公司开发的比较成熟、经得起实际考验的服务框架组合起来,通过 Spring Boot 风格进行再封装,屏蔽了复杂的配置和实现原理,最终给开发者提供了一套简单易懂、易部署和易维护的分布式系统开发工具包
  • 可以有效减少我们在组件的选型和整合上花费的精力,所以它可以帮助我们快速构建起基础的微服务架构系统
  • 总结:Spring Cloud 是一套标准的开发规范,是微服务架构的“一篮子”解决方案。

为什么会出现?

  • 企业业务发展早期一般采用单块架构,但是随着业务和团队规模的不断扩张,原来单块架构逐渐成为阻碍业务规模化和快速创新的瓶颈。
  • 企业的业务复杂性和团队规模到达一个点,那么单块应用由于耦合等因素,生产率会急剧下滑,这个时候就需要考虑拆分成微服务
  • 微服务最终的目标是实现业务价值,交付业务价值,但是为了让开发人员能够专注于业务交付,微服务需要底层基础设施的支撑,这些基础设施也称为微服务的公共关注点(common concerns)。
  • 如果把微服务的这些关注点,把它们抽象封装和沉淀下,最终产生的软件产品就是微服务开发框架。
  • Spring Cloud 正是在应对大规模微服务开发带来的挑战时,演进沉淀并且开源贡献给社区的解决方案

在什么场景下使用?

  • Spring Cloud 其目标旨在构建一套标准化的微服务解决方案让架构师、开发者在使用微服务理念构建应用系统的时候,面对各个环节的问题都可以找到相应的组件来处理
  • 有效减少我们在组件的选型和整合上花费的精力,帮助我们快速构建起基础的微服务架构系统。

它是一个解决微服务架构实施的综合性解决框架,它整合了诸多被广泛实践和证明过的框架作为实施的基础部件,又在该体系基础上创建了一些非常优秀的边缘组件


解决了什么问题?

  • Spring Cloud为开发人员提供了用于快速构建分布式系统中某些常见模式的工具(例如,配置管理,服务发现,断路器,智能路由,微代理,控制总线)
  • 通过 Spring Cloud ,使用一些简单的批注,就可以快速启用和配置应用程序内部的通用模式,并使用经过测试的组件构建大型分布式系统。

定位:Spring Cloud 专注于为典型的用例和扩展机制提供良好的开箱即用体验

Main Projects:

  • Spring Cloud Config,配置中心。
  • Spring Cloud Netflix,提供的模式包括服务发现(Eureka),断路器(Hystrix),智能路由(Zuul)和客户端负载平衡(Ribbon)。
  • Spring Cloud Gateway,网关。
  • Spring Cloud OpenFeign,声明式 REST 调用。
  • Spring Cloud Sleuth,微服务分布式链路跟踪。
  • Spring Cloud Bus,
  • Spring Cloud Alibaba

Spring、Spring Boot、Spring Cloud 的关系

Spring 框架为解决企业应用开发的复杂性而创建的框架,为开发 Java 应用程序提供了全面的基础架构支持。

Spring Boot 是 Spring 框架的扩展和自动化,它消除了在 Spring 中需要进行的 XML(Extensible Markup Language) 文件配置,使得开发变得更快、更高效、更自动化。

Spring Cloud 是一套分布式服务治理框架,它本身不提供具体功能性的操作,只专注于服务之间的通信、熔断和监控等。因此,需要很多组件来共同支持一套功能。

Spring Boot 要依赖 Spring 的,它是 Spring 的自动化。Spring Cloud 通过依赖 Spring Boot 来构建微服务应用。Spring Cloud 专注于全局的服务治理。


Spring Cloud 与 Spring Boot 常用的版本实践:

  • Spring Cloud Finchley.SR4 + Spring Boot 2.0.8.RELEASE
  • Spring Cloud Greenwich.RELEASE + Spring Boot 2.1.2.RELEASE
  • Spring Cloud Greenwich.SR1 + Spring Boot 2.1.3.RELEASE
  • Spring Cloud Greenwich.SR2 + Spring Boot 2.1.8.RELEASE
  • Spring Cloud Greenwich.SR6 + Spring Boot 2.1.18.RELEASE
  • Spring Cloud Hoxton.SR9 + Spring Boot 2.3.7.RELEASE
  • Spring Cloud Hoxton.SR12 + Spring Boot 2.3.12.RELEASE

公众号

知行chen

参考

官方网站 https://spring.io/projects/spring-cloud#overview

官方文档 https://docs.spring.io/spring-cloud/docs/Hoxton.SR12/reference/html/

Spring Cloud Greenwich中文文档 https://www.springcloud.cc/spring-cloud-greenwich.html

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值