写于:2018-12-13 08:52:37 文章对应版本:Greenwich.SR1

一、Introduce

官方介绍

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). 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.

粗略翻译:

Spring Coud 是快速构建分布式系统组件的一个开发工具(组件)。它包括 配置管理,服务发现,断路由,智能路由,微代理,控制总线。使用这些组件可以快速的构建应用程序。这些程序能能够很好的运行在自己的电脑,远程数据中心,云服务平台等各种分布式环境中。

Features

Spring Cloud 侧重于为典型用例提供良好的开箱即用体验,和提供扩展机制来覆盖其他用例。其提供的功能如下:

  • Distributed/versioned configuration 分布式配置
  • Service registration and discovery 服务注册发现
  • routing 路由
  • Service-to-service calls 服务调用
  • Load balancing 负载均衡
  • Circuit breakers 断路由
  • Distributed messaging 分布式消息

二、Microservices architecture VS SOA

Spring Cloud 是 Microservices architecture 的一套解决方案,对比于早期的 SOA 两者有什么区别和共性。

service-oriented architecture (SOA)

wiki 对 SOA 的介绍
03.png

A service-oriented architecture (SOA) is a style of software design where services are provided to the other components by application components, through a communication protocol over a network. The basic principles of service-oriented architecture are independent of vendors, products and technologies.[1] A service is a discrete unit of functionality that can be accessed remotely and acted upon and updated independently, such as retrieving a credit card statement online.

粗略翻译

soa 是服务组件之间通过协议在网络中进行服务生产消费的软件设计模式。每一个服务都是独立的单元进行远程的存取操作,就像在线检索信用卡账单。

SOA 架构是单一应用遇到瓶颈时进行架构扩展的一种解决方案。

优点:SOA 通过将业务功能进行拆分,拆分成不同的服务,不同服务进行各自的部署,解决了代码随着业务复杂度提升的问题以及单一应用性能瓶颈的问题。

缺点:web service 间通讯是通过向 web service 目录注册获取服务列表完成的,这使得 web service 目录会成为系统高可用的瓶颈。同时,webservice 在服务间采用 SOAP 协议【SOAP百度百科】,而 SOAP 协议结构复杂,数据量大,造成网络开销大,会存在导致系统响应慢等问题。

Microservices architecture

04.jpg
wiki 对 Microservices architecture 的介绍

Microservices are a software development technique—a variant of the service-oriented architecture (SOA) architectural style that structures an application as a collection of loosely coupled services. In a microservices architecture, services are fine-grained and the protocols are lightweight. The benefit of decomposing an application into different smaller services is that it improves modularity. This makes the application easier to understand, develop, test, and become more resilient to architecture erosion.[1] It parallelizes development by enabling small autonomous teams to develop, deploy and scale their respective services independently.[2] It also allows the architecture of an individual service to emerge through continuous refactoring.[3] Microservices-based architectures enable continuous delivery and deployment

粗略翻译

微服务是软件开发技术,不同于 SOA 面向服务开发将一个个松散的服务进行组合。微服务架构中,每个服务都是一个细粒度的,使用轻量级协议的小的应用程序。这使得每个应用职责更清晰,更容易开发测试。能够投入更少的人力去维护相关的模块代码。

Spring Cloud 是 Microservices architecture 的一站式解决方案。

优点:Microservices architecture 汲取了 SOA 的架构思想演变的一种新的架构模式。不同于 SOA 的服务化,Microservices architecture 直接将某一个功能独立成一个服务应用,支持独立部署,独立开发,独立数据库,在不考虑业务场景的情况下,能够独立部署,独立运行。服务间通过轻量级协议,如:Http 协议进行通讯,使得整个应用开发能够快速,敏捷上限。

缺点:Microservices architecture 细化了业务功能,由不同的开发组进行开发,无形中增加了沟通成本,随着业务扩展,后期服务变多,服务间的运维部署也会成为挑战。系统问题排查,定位同样会带来挑战。

三、Cloud Native Applications

spring-cloud-Edgware.SR1

Cloud Native is a style of application development that encourages easy adoption of best practices in the areas of continuous delivery and value-driven development

粗略翻译

云原生是一种应用开发风格, 在支持交付和价值驱动领域更容易被采用的最好的实践。

个人理解为:就是通过同一个的标准开发程序应用,然后通过统一的方式进行交付,应用从开发到上线是一套流水线式的操作。

12-factor Apps

云原生规定了一个应用构建所包含的 12个因素

其中12个因素如下(参考)

  • Codebase[代码库]

    One codebase tracked in revision control, many deploys

  • Dependencies[依赖]

    Explicitly declare and isolate dependencies

  • Config[配置]

    Store config in the environment

  • Backing services[基础服务]

    Treat backing services as attached resources

  • Build, release, run[编译,发布,运行]

    Strictly separate build and run stages

  • Processes[执行]

    Execute the app as one or more stateless processes

  • Port binding[端口绑定]

Export services via port binding

  • Concurrency[并发]

    Scale out via the process model

  • Disposability[便捷]

    Maximize robustness with fast startup and graceful shutdown

  • Dev/prod parity[开发,生产环境]

    Keep development, staging, and production as similar as possible

  • Logs[日志]

    Treat logs as event streams

  • Admin processes[管理流程]

    Run admin/management tasks as one-off processes

以上特性中的许多都包含在 Spring Boot 中,Spring Cloud 是在 Spring Boot 上构建的。

精彩内容推送,请关注公众号!

[spring-cloud]-概述 - 图3