springcloud 版本_4 年 46 个版本,一文读懂 Spring Cloud 发展历史

7b7116fd4ad4bf2fe9ea3464e762cc68.png

作者 | 方剑

责编 | 唐小引

头图 | CSDN 下载自东方 IC

出品 | CSDN(ID:CSDNnews)

Spring Cloud 自 2016 年 1 月发布第一个 Angel.SR5 版本,到目前 2020 年 3 月发布 Hoxton.SR3 版本,已经历经了 4 年时间。这 4 年时间里,Spring Cloud 一共发布了 46 个版本,支持的组件数从 5 个增加到 21 个。Spring Cloud 在 2019 年 12 月对外宣布后续 RoadMap:

  • 下一个版本 Ilford 版本是一个大版本。这个版本基于 Spring Framework 5.3 & Spring Boot 2.4,会在 2020 Q4 左右发布;

  • Ilford 版本会删除处于维护模式的项目。目前处于维护模式的 Netflix 大部分项目都会被删除(spring-cloud-netflix Github 项目已经删除了这些维护模式的项目);

  • 简化 Spring Cloud 发布列车。后续 IaasS 厂商对应的 Spring Cloud 项目会移出 Spring Cloud 组织,各自单独维护(spring-cloud-azure 一直都是单独维护,spring-cloud-alibaba 孵化在 Spring Cloud 组织,毕业后单独维护);

  • API 重构,会带来重大的改变(Spring Cloud Hoxton 版本新增了 Spring Cloud Circuit Breaker 用于统一熔断操作的编程模型和 Spring Cloud LoadBalanacer 用于处理客户端负载均衡并代替 Netflix Ribbon)。

这个 RoadMap 可以说是对 Spring Cloud 有着非常大的变化。

0239718614cce0904c40b6c6943ebca0.png

什么是 Spring Cloud?

首先先澄清「Spring Cloud = Spring Cloud Netflix」这个观点是错误的。官方对 Spring Cloud 的定义是提供分布式应用开发的一套共用模式,这个模式也可以理解成一套统一的抽象编程模型,底层的实现可以进行切换,比如可以从 Netflix 切换成 Alibaba,从 Zookeeper 切换成 Consul。

这套共用的模式有哪些呢?(可能比大家想象的要多。大家平时对常用的功能比较关心,实际上 Spring Cloud 整个体系内容非常还是多的。)

  • 服务注册/发现:Service Registry/Discovery。spring-cloud-commons 模块对服务注册/发现模型进行统一;

  • 分布式配置:Configuration Management。spring-core 模块对配置有 Environment 和 PropertySource 抽象,各个配置中心可以添加各自实现的 PropertySource;

  • 服务熔断:Circuit Breaker。spring-cloud-commons 模块对熔断器模式客户端调用模型进行统一(早期有个单独的项目 spring-cloud-circuit-breaker,后来合并到 spring-cloud-commons 模块);

  • 消息总线:Message Bus。spring-cloud-bus 模块定义远程事件,用来连接分布式系统上的各个节点,bus 强依赖 spring-cloud-stream 项目。

  • 分布式消息:Distributed Messaging。spring-cloud-stream 项目对消息编程模型统一;

  • 客户端负载均衡:Client Load Balancing。早期依赖 Netflix Ribbon 项目,目前可选择 spring-cloud-loadbanacer 模块(后续 Netflix Ribbon 不再维护);

  • 服务调用:Service-to-service calls。OpenFeign 提供声明式接口的方式进行服务调用;RestTemplate 提供基于服务名方式的服务调用;

  • 网关:Gateway。早期使用 Netflix Zuul,现在推荐使用 Spring Cloud Gateway;网关总体来说并不算是一个共用的模式,只是一个实现功能的组件;

  • 链路追踪:Tracing。Spring Cloud Sleuth 对 Spring Cloud 各个客户端埋点进行链路追踪,可以跟 Zipkin 整合;

  • 连接器:Spring Cloud Connectors。Connectors 表示跟 IaaS 厂商的连接器,如果本地开发使用本地 Eureka 和 MySQL,部署到云上(Cloud Foundry)这些地址会被自动替换成云上的地址(前期是购买这些服务)。这是 Cloud Foundry 的 Spring Cloud Connectors,当然还有其他 IaaS 厂商的实现比如 IBM、AWS;

  • FaaS:Spring Cloud Function。Spring Cloud 与 Serverless 集成关键的一个项目;

  • 任务调度:Spring Cloud Task 用于任务运行,可以在本地、云端甚至 Kubernetes 上运行;

  • 数据流:Spring Cloud Data Flow 可以配合 Spring Cloud Stream 完成流处理,配合 Spring Cloud Task 完成批处理,使用 Spring Cloud Deployer 进行应用的部署。

当然还有其他没有涉及到的模块比如 Spring Cloud Contract、Spring Cloud Open Service Broker、Spring Cloud Skipper、Spring Cloud Security 大家可以自行翻看资料了解。

这些功能也是 Spring Cloud 这 4 年发展迭代起来的。最早期 Spring Cloud 在统一编程模型上只有服务注册/发现以及配置管理。后续陆续添加了 Spring Cloud Circuit Breaker 统一熔断器编程模型,Spring Cloud Stream/Bus 消息编程模型统一,Spring Cloud OpenFeign 以声明式接口进行服务调用,Spring Cloud LoadBalancer 客户端负载均衡。

17f4bf30298b7f43c8008744e81ea6c8.png

Spring Cloud 现状

回顾 Spring Cloud 的发展历史,Spring Cloud 一度泛指 Spring Cloud Netflix,无论是 Spring 的母公司 Pivotal(VMWare) 对应的商业化产品 Cloud Foundry 内部的 Spring Cloud Services(Spring Cloud 商业化服务) 支持 Netflix Eureka,Netflix Hystrix,还是 Pivotal 官网 blog 上与 Netflix 相互背书,或者是 Spring Cloud 服务注册/发现模型借鉴 Netflix Eureka;可见两者关系十分紧密。

随着 Netflix 宣布 Eureka 2.0 不再开发,Hystrix、Ribbon、Archaius 不再维护,Zuul 被 Spring Cloud Gateway 代替。Spring Cloud 也宣布这些模块对应的在 spring-cloud-netflix 项目里的模块也不再维护,并且在 RoadMap 中宣布 Ilford 版本发布的时候删除这些维护模块。Netflix 在 Spring Cloud 历史中会逐渐消失。

0dec48564abdc74d634bde8520d67071.png

不过不用太担心。这 4 年的发展让 Spring Cloud 规范目前的实现者也不单单只有 Netflix 这一套。目前有 Spring Cloud Alibaba、Spring Cloud Consul、Spring Cloud Zookeeper、Spring Cloud Kubernetes,甚至 Spring Cloud 官方也有对应的实现组件比如 Spring Cloud Config 集成了 Git、SVN 或 Database 提供配置服务、Spring Cloud Stream RabbitMQ/Kafka 提供消息抽象的实现者。

这是目前 Spring Cloud 各个实现的总览:

5a382e203462f2555f0dcebba8d2b699.png

目前非常不建议大家继续使用 Spring Cloud Netflix 这套实现。因为目前 spring-cloud-netflix 项目里的维护项目已经在 Github 上已经被删除。这意味着 Spring Cloud Netflix "删库" 动作已经开始执行了。

9384472cee71420c02931271a7172d9e.png 62c8b46ea7091bd4922e6fb7856848bb.png

Spring Cloud Hoxton 版本介绍

Spring Cloud Hoxton 版本在 2019 年 11 月发布,这是目前 Spring Cloud 最新的大版本。主要的特性包括:

  • 基于 Spring Boot 2.2.1.RELEASE(全局懒加载、性能、CP 构造器……);

  • 全新的熔断编程模型:Spring Cloud Circuit Breaker;

  • 新客户端负载均衡组件:Spring Cloud LoadBalancer;

  • 继续对 Reactive 支持,服务发现支持 ReactiveDiscoveryClient,全新的熔断编程模型支持 ReactiveCircuitBreaker,新客户端负载均衡使用 ReactiveLoadBalancer。

Spring Cloud Circuit Breaker 统一了熔断器编程模型,这是一段使用 Sentinel CircuitBreaker 进行保护的代码:

CircuitBreaker circuitBreaker = factory.create("sentinel");
return circuitBreaker.run( -> {
return restTemplate.getForObject("https://httpbin.org/status/500
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值