欢迎光临
我们一直在努力

2、绪论与软件架构概述

在这里插入图片描述

📘 系统架构设计师学习笔记(一):绪论与软件架构概述

从概念到实战:系统架构的本质、发展历程、5大架构风格及“4+1”视图模型全解

📑 目录

  • 1. 系统架构的基本概念
  • 2. 软件架构的发展阶段
  • 3. 5种常用软件架构风格(★★★)
    • 3.1 分层架构
    • 3.2 事件驱动架构
    • 3.3 微核架构(插件架构)
    • 3.4 微服务架构
    • 3.5 云架构
  • 4. 通用架构风格分类
    • 4.1 数据流风格
    • 4.2 调用/返回风格
    • 4.3 独立构件风格
    • 4.4 虚拟机风格
    • 4.5 仓库风格
    • 4.6 C2风格
  • 5. 软件架构的4种建模方法
  • 6. “4+1”视图模型
  • 7. 架构风格适用场景速查表
  • 8. 经典真题演练

1. 系统架构的基本概念

架构(IEEE定义):体现组件中的系统基本组织、组件彼此关系及与环境的关系,以及指导其设计和发展的原则。

系统架构:系统的一种整体高层次结构表示,是系统的骨架和根基,包括组件、连接件、约束规范以及演化原理。

架构设计的作用:

  • 解决复杂需求分析问题
  • 处理非功能属性(性能、安全性、可维护性)设计
  • 支撑长生命周期、高扩展性系统结构
  • 实现基于组件的集成
  • 支持业务流程再造

💡 系统架构设计是连接用户需求与详细设计实现的桥梁,也是早期质量保证的关键。


2. 软件架构的发展阶段

#mermaid-svg-X32T2U2V1Fd4AhX2{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-X32T2U2V1Fd4AhX2 .error-icon{fill:#552222;}#mermaid-svg-X32T2U2V1Fd4AhX2 .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-X32T2U2V1Fd4AhX2 .marker{fill:#333333;stroke:#333333;}#mermaid-svg-X32T2U2V1Fd4AhX2 .marker.cross{stroke:#333333;}#mermaid-svg-X32T2U2V1Fd4AhX2 svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-X32T2U2V1Fd4AhX2 p{margin:0;}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge{stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section–1 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section–1 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section–1 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section–1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section–1 text{fill:#ffffff;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon–1{font-size:40px;color:#ffffff;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge–1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth–1{stroke-width:17;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section–1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:#ffffff;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-0 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-0 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-0 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-0 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-0{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-0{stroke-width:14;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-1 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-1 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-1 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-1 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-1{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-1{stroke-width:11;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-2 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-2 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-2 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-2 text{fill:#ffffff;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-2{stroke-width:8;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:#ffffff;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-3 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-3 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-3 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-3 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-3{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-3{stroke-width:5;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-4 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-4 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-4 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-4 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-4{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-4{stroke-width:2;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-5 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-5 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-5 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-5 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-5{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-5{stroke-width:-1;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-6 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-6 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-6 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-6 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-6{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-6{stroke-width:-4;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-7 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-7 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-7 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-7 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-7{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-7{stroke-width:-7;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-8 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-8 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-8 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-8 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-8{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-8{stroke-width:-10;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-9 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-9 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-9 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-9 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-9{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-9{stroke-width:-13;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-10 rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-10 path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-10 circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-10 text{fill:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .node-icon-10{font-size:40px;color:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge-depth-10{stroke-width:-16;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-X32T2U2V1Fd4AhX2 .lineWrapper line{stroke:black;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled circle,#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:lightgray;}#mermaid-svg-X32T2U2V1Fd4AhX2 .disabled text{fill:#efefef;}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-root rect,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-root path,#mermaid-svg-X32T2U2V1Fd4AhX2 .section-root circle{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-X32T2U2V1Fd4AhX2 .section-root text{fill:#ffffff;}#mermaid-svg-X32T2U2V1Fd4AhX2 .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-X32T2U2V1Fd4AhX2 .edge{fill:none;}#mermaid-svg-X32T2U2V1Fd4AhX2 .eventWrapper{filter:brightness(120%);}#mermaid-svg-X32T2U2V1Fd4AhX2 :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

基础研究阶段

模块化开发

高内聚低耦合

模块大小适度

接口简单精炼

概念体系形成

组件化技术

可组装/可插拔

依赖平台/容器

比模块化更独立

理论体系完善

架构描述/分析/设计

架构风格

动态架构

架构重用

普及应用

贯穿软件生命周期

影响开发各阶段

成为核心产物

软件架构四阶段演进

阶段核心成果特点
基础研究 模块化开发 逻辑切分,高内聚低耦合,扇入扇出控制
概念体系形成 组件化技术 物理隔离,可组装可插拔,依赖容器
理论体系完善 架构描述/分析/设计 架构风格、动态架构、架构重用
普及应用 全生命周期集成 架构成为软件核心产物

3. 5种常用软件架构风格(★★★)

考试高频考点!以下5种是近年案例分析及选择题常考内容。

3.1 分层架构

将软件分为若干水平层,每层有清晰角色,通过接口通信。

#mermaid-svg-113o9eN6CWn7MrRw{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-113o9eN6CWn7MrRw .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-113o9eN6CWn7MrRw .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-113o9eN6CWn7MrRw .error-icon{fill:#552222;}#mermaid-svg-113o9eN6CWn7MrRw .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-113o9eN6CWn7MrRw .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-113o9eN6CWn7MrRw .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-113o9eN6CWn7MrRw .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-113o9eN6CWn7MrRw .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-113o9eN6CWn7MrRw .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-113o9eN6CWn7MrRw .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-113o9eN6CWn7MrRw .marker{fill:#333333;stroke:#333333;}#mermaid-svg-113o9eN6CWn7MrRw .marker.cross{stroke:#333333;}#mermaid-svg-113o9eN6CWn7MrRw svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-113o9eN6CWn7MrRw p{margin:0;}#mermaid-svg-113o9eN6CWn7MrRw .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-113o9eN6CWn7MrRw .cluster-label text{fill:#333;}#mermaid-svg-113o9eN6CWn7MrRw .cluster-label span{color:#333;}#mermaid-svg-113o9eN6CWn7MrRw .cluster-label span p{background-color:transparent;}#mermaid-svg-113o9eN6CWn7MrRw .label text,#mermaid-svg-113o9eN6CWn7MrRw span{fill:#333;color:#333;}#mermaid-svg-113o9eN6CWn7MrRw .node rect,#mermaid-svg-113o9eN6CWn7MrRw .node circle,#mermaid-svg-113o9eN6CWn7MrRw .node ellipse,#mermaid-svg-113o9eN6CWn7MrRw .node polygon,#mermaid-svg-113o9eN6CWn7MrRw .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-113o9eN6CWn7MrRw .rough-node .label text,#mermaid-svg-113o9eN6CWn7MrRw .node .label text,#mermaid-svg-113o9eN6CWn7MrRw .image-shape .label,#mermaid-svg-113o9eN6CWn7MrRw .icon-shape .label{text-anchor:middle;}#mermaid-svg-113o9eN6CWn7MrRw .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-113o9eN6CWn7MrRw .rough-node .label,#mermaid-svg-113o9eN6CWn7MrRw .node .label,#mermaid-svg-113o9eN6CWn7MrRw .image-shape .label,#mermaid-svg-113o9eN6CWn7MrRw .icon-shape .label{text-align:center;}#mermaid-svg-113o9eN6CWn7MrRw .node.clickable{cursor:pointer;}#mermaid-svg-113o9eN6CWn7MrRw .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-113o9eN6CWn7MrRw .arrowheadPath{fill:#333333;}#mermaid-svg-113o9eN6CWn7MrRw .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-113o9eN6CWn7MrRw .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-113o9eN6CWn7MrRw .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-113o9eN6CWn7MrRw .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-113o9eN6CWn7MrRw .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-113o9eN6CWn7MrRw .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-113o9eN6CWn7MrRw .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-113o9eN6CWn7MrRw .cluster text{fill:#333;}#mermaid-svg-113o9eN6CWn7MrRw .cluster span{color:#333;}#mermaid-svg-113o9eN6CWn7MrRw div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-113o9eN6CWn7MrRw .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-113o9eN6CWn7MrRw rect.text{fill:none;stroke-width:0;}#mermaid-svg-113o9eN6CWn7MrRw .icon-shape,#mermaid-svg-113o9eN6CWn7MrRw .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-113o9eN6CWn7MrRw .icon-shape p,#mermaid-svg-113o9eN6CWn7MrRw .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-113o9eN6CWn7MrRw .icon-shape .label rect,#mermaid-svg-113o9eN6CWn7MrRw .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-113o9eN6CWn7MrRw .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-113o9eN6CWn7MrRw .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-113o9eN6CWn7MrRw :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

分层架构

表现层 Presentation Layer用户界面/交互

业务层 Business Layer业务逻辑实现

持久层 Persistence Layer数据访问/SQL

数据库层 Database Layer数据存储

可选:服务层 Service Layer

特点:请求必须逐层传递,不能跨层调用。

3.2 事件驱动架构

通过事件进行通信,是一种分布式异步架构,适用于松散耦合系统。

#mermaid-svg-EhkjpQyoEuzGIYUP{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-EhkjpQyoEuzGIYUP .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-EhkjpQyoEuzGIYUP .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-EhkjpQyoEuzGIYUP .error-icon{fill:#552222;}#mermaid-svg-EhkjpQyoEuzGIYUP .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-EhkjpQyoEuzGIYUP .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-EhkjpQyoEuzGIYUP .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-EhkjpQyoEuzGIYUP .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-EhkjpQyoEuzGIYUP .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-EhkjpQyoEuzGIYUP .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-EhkjpQyoEuzGIYUP .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-EhkjpQyoEuzGIYUP .marker{fill:#333333;stroke:#333333;}#mermaid-svg-EhkjpQyoEuzGIYUP .marker.cross{stroke:#333333;}#mermaid-svg-EhkjpQyoEuzGIYUP svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-EhkjpQyoEuzGIYUP p{margin:0;}#mermaid-svg-EhkjpQyoEuzGIYUP .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-EhkjpQyoEuzGIYUP .cluster-label text{fill:#333;}#mermaid-svg-EhkjpQyoEuzGIYUP .cluster-label span{color:#333;}#mermaid-svg-EhkjpQyoEuzGIYUP .cluster-label span p{background-color:transparent;}#mermaid-svg-EhkjpQyoEuzGIYUP .label text,#mermaid-svg-EhkjpQyoEuzGIYUP span{fill:#333;color:#333;}#mermaid-svg-EhkjpQyoEuzGIYUP .node rect,#mermaid-svg-EhkjpQyoEuzGIYUP .node circle,#mermaid-svg-EhkjpQyoEuzGIYUP .node ellipse,#mermaid-svg-EhkjpQyoEuzGIYUP .node polygon,#mermaid-svg-EhkjpQyoEuzGIYUP .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-EhkjpQyoEuzGIYUP .rough-node .label text,#mermaid-svg-EhkjpQyoEuzGIYUP .node .label text,#mermaid-svg-EhkjpQyoEuzGIYUP .image-shape .label,#mermaid-svg-EhkjpQyoEuzGIYUP .icon-shape .label{text-anchor:middle;}#mermaid-svg-EhkjpQyoEuzGIYUP .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-EhkjpQyoEuzGIYUP .rough-node .label,#mermaid-svg-EhkjpQyoEuzGIYUP .node .label,#mermaid-svg-EhkjpQyoEuzGIYUP .image-shape .label,#mermaid-svg-EhkjpQyoEuzGIYUP .icon-shape .label{text-align:center;}#mermaid-svg-EhkjpQyoEuzGIYUP .node.clickable{cursor:pointer;}#mermaid-svg-EhkjpQyoEuzGIYUP .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-EhkjpQyoEuzGIYUP .arrowheadPath{fill:#333333;}#mermaid-svg-EhkjpQyoEuzGIYUP .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-EhkjpQyoEuzGIYUP .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-EhkjpQyoEuzGIYUP .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-EhkjpQyoEuzGIYUP .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-EhkjpQyoEuzGIYUP .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-EhkjpQyoEuzGIYUP .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-EhkjpQyoEuzGIYUP .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-EhkjpQyoEuzGIYUP .cluster text{fill:#333;}#mermaid-svg-EhkjpQyoEuzGIYUP .cluster span{color:#333;}#mermaid-svg-EhkjpQyoEuzGIYUP div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-EhkjpQyoEuzGIYUP .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-EhkjpQyoEuzGIYUP rect.text{fill:none;stroke-width:0;}#mermaid-svg-EhkjpQyoEuzGIYUP .icon-shape,#mermaid-svg-EhkjpQyoEuzGIYUP .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-EhkjpQyoEuzGIYUP .icon-shape p,#mermaid-svg-EhkjpQyoEuzGIYUP .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-EhkjpQyoEuzGIYUP .icon-shape .label rect,#mermaid-svg-EhkjpQyoEuzGIYUP .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-EhkjpQyoEuzGIYUP .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-EhkjpQyoEuzGIYUP .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-EhkjpQyoEuzGIYUP :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

事件源

事件队列

分发器

事件通道

事件处理器

新事件

四部分:事件队列、分发器、事件通道、事件处理器。简单项目可合并为“事件代理+处理器”。

3.3 微核架构(插件架构)

内核只包含最小功能(模块加载、通信),业务逻辑通过插件实现。

#mermaid-svg-TFPxkG8kIR4puwZS{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-TFPxkG8kIR4puwZS .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-TFPxkG8kIR4puwZS .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-TFPxkG8kIR4puwZS .error-icon{fill:#552222;}#mermaid-svg-TFPxkG8kIR4puwZS .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-TFPxkG8kIR4puwZS .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-TFPxkG8kIR4puwZS .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-TFPxkG8kIR4puwZS .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-TFPxkG8kIR4puwZS .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-TFPxkG8kIR4puwZS .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-TFPxkG8kIR4puwZS .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-TFPxkG8kIR4puwZS .marker{fill:#333333;stroke:#333333;}#mermaid-svg-TFPxkG8kIR4puwZS .marker.cross{stroke:#333333;}#mermaid-svg-TFPxkG8kIR4puwZS svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-TFPxkG8kIR4puwZS p{margin:0;}#mermaid-svg-TFPxkG8kIR4puwZS .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-TFPxkG8kIR4puwZS .cluster-label text{fill:#333;}#mermaid-svg-TFPxkG8kIR4puwZS .cluster-label span{color:#333;}#mermaid-svg-TFPxkG8kIR4puwZS .cluster-label span p{background-color:transparent;}#mermaid-svg-TFPxkG8kIR4puwZS .label text,#mermaid-svg-TFPxkG8kIR4puwZS span{fill:#333;color:#333;}#mermaid-svg-TFPxkG8kIR4puwZS .node rect,#mermaid-svg-TFPxkG8kIR4puwZS .node circle,#mermaid-svg-TFPxkG8kIR4puwZS .node ellipse,#mermaid-svg-TFPxkG8kIR4puwZS .node polygon,#mermaid-svg-TFPxkG8kIR4puwZS .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-TFPxkG8kIR4puwZS .rough-node .label text,#mermaid-svg-TFPxkG8kIR4puwZS .node .label text,#mermaid-svg-TFPxkG8kIR4puwZS .image-shape .label,#mermaid-svg-TFPxkG8kIR4puwZS .icon-shape .label{text-anchor:middle;}#mermaid-svg-TFPxkG8kIR4puwZS .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-TFPxkG8kIR4puwZS .rough-node .label,#mermaid-svg-TFPxkG8kIR4puwZS .node .label,#mermaid-svg-TFPxkG8kIR4puwZS .image-shape .label,#mermaid-svg-TFPxkG8kIR4puwZS .icon-shape .label{text-align:center;}#mermaid-svg-TFPxkG8kIR4puwZS .node.clickable{cursor:pointer;}#mermaid-svg-TFPxkG8kIR4puwZS .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-TFPxkG8kIR4puwZS .arrowheadPath{fill:#333333;}#mermaid-svg-TFPxkG8kIR4puwZS .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-TFPxkG8kIR4puwZS .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-TFPxkG8kIR4puwZS .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-TFPxkG8kIR4puwZS .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-TFPxkG8kIR4puwZS .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-TFPxkG8kIR4puwZS .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-TFPxkG8kIR4puwZS .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-TFPxkG8kIR4puwZS .cluster text{fill:#333;}#mermaid-svg-TFPxkG8kIR4puwZS .cluster span{color:#333;}#mermaid-svg-TFPxkG8kIR4puwZS div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-TFPxkG8kIR4puwZS .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-TFPxkG8kIR4puwZS rect.text{fill:none;stroke-width:0;}#mermaid-svg-TFPxkG8kIR4puwZS .icon-shape,#mermaid-svg-TFPxkG8kIR4puwZS .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-TFPxkG8kIR4puwZS .icon-shape p,#mermaid-svg-TFPxkG8kIR4puwZS .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-TFPxkG8kIR4puwZS .icon-shape .label rect,#mermaid-svg-TFPxkG8kIR4puwZS .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-TFPxkG8kIR4puwZS .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-TFPxkG8kIR4puwZS .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-TFPxkG8kIR4puwZS :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

核心系统 Core模块加载/通信/最小功能

插件1业务逻辑A

插件2业务逻辑B

插件3业务逻辑C

特点:插件互相独立,减少依赖。

3.4 微服务架构

SOA的升级版,每个服务是独立部署单元,通过REST/SOAP等远程协议通信。

#mermaid-svg-XBLAKp2LXQnbLgKp{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-XBLAKp2LXQnbLgKp .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-XBLAKp2LXQnbLgKp .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-XBLAKp2LXQnbLgKp .error-icon{fill:#552222;}#mermaid-svg-XBLAKp2LXQnbLgKp .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-XBLAKp2LXQnbLgKp .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-XBLAKp2LXQnbLgKp .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-XBLAKp2LXQnbLgKp .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-XBLAKp2LXQnbLgKp .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-XBLAKp2LXQnbLgKp .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-XBLAKp2LXQnbLgKp .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-XBLAKp2LXQnbLgKp .marker{fill:#333333;stroke:#333333;}#mermaid-svg-XBLAKp2LXQnbLgKp .marker.cross{stroke:#333333;}#mermaid-svg-XBLAKp2LXQnbLgKp svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-XBLAKp2LXQnbLgKp p{margin:0;}#mermaid-svg-XBLAKp2LXQnbLgKp .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-XBLAKp2LXQnbLgKp .cluster-label text{fill:#333;}#mermaid-svg-XBLAKp2LXQnbLgKp .cluster-label span{color:#333;}#mermaid-svg-XBLAKp2LXQnbLgKp .cluster-label span p{background-color:transparent;}#mermaid-svg-XBLAKp2LXQnbLgKp .label text,#mermaid-svg-XBLAKp2LXQnbLgKp span{fill:#333;color:#333;}#mermaid-svg-XBLAKp2LXQnbLgKp .node rect,#mermaid-svg-XBLAKp2LXQnbLgKp .node circle,#mermaid-svg-XBLAKp2LXQnbLgKp .node ellipse,#mermaid-svg-XBLAKp2LXQnbLgKp .node polygon,#mermaid-svg-XBLAKp2LXQnbLgKp .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-XBLAKp2LXQnbLgKp .rough-node .label text,#mermaid-svg-XBLAKp2LXQnbLgKp .node .label text,#mermaid-svg-XBLAKp2LXQnbLgKp .image-shape .label,#mermaid-svg-XBLAKp2LXQnbLgKp .icon-shape .label{text-anchor:middle;}#mermaid-svg-XBLAKp2LXQnbLgKp .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-XBLAKp2LXQnbLgKp .rough-node .label,#mermaid-svg-XBLAKp2LXQnbLgKp .node .label,#mermaid-svg-XBLAKp2LXQnbLgKp .image-shape .label,#mermaid-svg-XBLAKp2LXQnbLgKp .icon-shape .label{text-align:center;}#mermaid-svg-XBLAKp2LXQnbLgKp .node.clickable{cursor:pointer;}#mermaid-svg-XBLAKp2LXQnbLgKp .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-XBLAKp2LXQnbLgKp .arrowheadPath{fill:#333333;}#mermaid-svg-XBLAKp2LXQnbLgKp .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-XBLAKp2LXQnbLgKp .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-XBLAKp2LXQnbLgKp .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-XBLAKp2LXQnbLgKp .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-XBLAKp2LXQnbLgKp .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-XBLAKp2LXQnbLgKp .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-XBLAKp2LXQnbLgKp .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-XBLAKp2LXQnbLgKp .cluster text{fill:#333;}#mermaid-svg-XBLAKp2LXQnbLgKp .cluster span{color:#333;}#mermaid-svg-XBLAKp2LXQnbLgKp div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-XBLAKp2LXQnbLgKp .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-XBLAKp2LXQnbLgKp rect.text{fill:none;stroke-width:0;}#mermaid-svg-XBLAKp2LXQnbLgKp .icon-shape,#mermaid-svg-XBLAKp2LXQnbLgKp .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-XBLAKp2LXQnbLgKp .icon-shape p,#mermaid-svg-XBLAKp2LXQnbLgKp .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-XBLAKp2LXQnbLgKp .icon-shape .label rect,#mermaid-svg-XBLAKp2LXQnbLgKp .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-XBLAKp2LXQnbLgKp .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-XBLAKp2LXQnbLgKp .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-XBLAKp2LXQnbLgKp :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

微服务架构

Client

API_Gateway

订单服务

用户服务

库存服务

订单DB

用户DB

库存DB

三种实现模式:

  • RESTful API模式(云服务)
  • RESTful应用模式(企业内部)
  • 集中消息模式(消息代理,注意单点故障)

3.5 云架构

主要解决扩展性和并发问题,将数据复制到内存中,形成可复制的内存数据单元。

#mermaid-svg-UTIyRVLDtXTkZ2qq{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-UTIyRVLDtXTkZ2qq .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-UTIyRVLDtXTkZ2qq .error-icon{fill:#552222;}#mermaid-svg-UTIyRVLDtXTkZ2qq .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-UTIyRVLDtXTkZ2qq .marker{fill:#333333;stroke:#333333;}#mermaid-svg-UTIyRVLDtXTkZ2qq .marker.cross{stroke:#333333;}#mermaid-svg-UTIyRVLDtXTkZ2qq svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-UTIyRVLDtXTkZ2qq p{margin:0;}#mermaid-svg-UTIyRVLDtXTkZ2qq .label{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;color:#333;}#mermaid-svg-UTIyRVLDtXTkZ2qq .cluster-label text{fill:#333;}#mermaid-svg-UTIyRVLDtXTkZ2qq .cluster-label span{color:#333;}#mermaid-svg-UTIyRVLDtXTkZ2qq .cluster-label span p{background-color:transparent;}#mermaid-svg-UTIyRVLDtXTkZ2qq .label text,#mermaid-svg-UTIyRVLDtXTkZ2qq span{fill:#333;color:#333;}#mermaid-svg-UTIyRVLDtXTkZ2qq .node rect,#mermaid-svg-UTIyRVLDtXTkZ2qq .node circle,#mermaid-svg-UTIyRVLDtXTkZ2qq .node ellipse,#mermaid-svg-UTIyRVLDtXTkZ2qq .node polygon,#mermaid-svg-UTIyRVLDtXTkZ2qq .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-UTIyRVLDtXTkZ2qq .rough-node .label text,#mermaid-svg-UTIyRVLDtXTkZ2qq .node .label text,#mermaid-svg-UTIyRVLDtXTkZ2qq .image-shape .label,#mermaid-svg-UTIyRVLDtXTkZ2qq .icon-shape .label{text-anchor:middle;}#mermaid-svg-UTIyRVLDtXTkZ2qq .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-UTIyRVLDtXTkZ2qq .rough-node .label,#mermaid-svg-UTIyRVLDtXTkZ2qq .node .label,#mermaid-svg-UTIyRVLDtXTkZ2qq .image-shape .label,#mermaid-svg-UTIyRVLDtXTkZ2qq .icon-shape .label{text-align:center;}#mermaid-svg-UTIyRVLDtXTkZ2qq .node.clickable{cursor:pointer;}#mermaid-svg-UTIyRVLDtXTkZ2qq .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-UTIyRVLDtXTkZ2qq .arrowheadPath{fill:#333333;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-UTIyRVLDtXTkZ2qq .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UTIyRVLDtXTkZ2qq .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-UTIyRVLDtXTkZ2qq .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UTIyRVLDtXTkZ2qq .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-UTIyRVLDtXTkZ2qq .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-UTIyRVLDtXTkZ2qq .cluster text{fill:#333;}#mermaid-svg-UTIyRVLDtXTkZ2qq .cluster span{color:#333;}#mermaid-svg-UTIyRVLDtXTkZ2qq div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-UTIyRVLDtXTkZ2qq .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-UTIyRVLDtXTkZ2qq rect.text{fill:none;stroke-width:0;}#mermaid-svg-UTIyRVLDtXTkZ2qq .icon-shape,#mermaid-svg-UTIyRVLDtXTkZ2qq .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-UTIyRVLDtXTkZ2qq .icon-shape p,#mermaid-svg-UTIyRVLDtXTkZ2qq .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-UTIyRVLDtXTkZ2qq .icon-shape .label rect,#mermaid-svg-UTIyRVLDtXTkZ2qq .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-UTIyRVLDtXTkZ2qq .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-UTIyRVLDtXTkZ2qq .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-UTIyRVLDtXTkZ2qq :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

云架构

管理请求/会话

管理请求/会话

管理请求/会话

数据复制

数据复制

数据复制

虚拟中间件

处理单元1

处理单元2

处理单元3

虚拟中间件包含:消息中间件、数据中间件、处理中间件、部署中间件。


4. 通用架构风格分类

根据任铄老师课程整理,共6大类:

#mermaid-svg-HlXMHdSC3FEoJnpR{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-HlXMHdSC3FEoJnpR .error-icon{fill:#552222;}#mermaid-svg-HlXMHdSC3FEoJnpR .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-HlXMHdSC3FEoJnpR .marker{fill:#333333;stroke:#333333;}#mermaid-svg-HlXMHdSC3FEoJnpR .marker.cross{stroke:#333333;}#mermaid-svg-HlXMHdSC3FEoJnpR svg{font-family:\”trebuchet ms\”,verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-HlXMHdSC3FEoJnpR p{margin:0;}#mermaid-svg-HlXMHdSC3FEoJnpR .edge{stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .section–1 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section–1 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section–1 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section–1 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section–1 path{fill:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section–1 text{fill:#ffffff;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon–1{font-size:40px;color:#ffffff;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge–1{stroke:hsl(240, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth–1{stroke-width:17;}#mermaid-svg-HlXMHdSC3FEoJnpR .section–1 line{stroke:hsl(60, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-0 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-0 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-0 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-0 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-0 path{fill:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-0 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-0{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-0{stroke:hsl(60, 100%, 73.5294117647%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-0{stroke-width:14;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-0 line{stroke:hsl(240, 100%, 83.5294117647%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-1 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-1 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-1 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-1 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-1 path{fill:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-1 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-1{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-1{stroke:hsl(80, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-1{stroke-width:11;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-1 line{stroke:hsl(260, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-2 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-2 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-2 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-2 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-2 path{fill:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-2 text{fill:#ffffff;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-2{font-size:40px;color:#ffffff;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-2{stroke:hsl(270, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-2{stroke-width:8;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-2 line{stroke:hsl(90, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-3 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-3 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-3 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-3 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-3 path{fill:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-3 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-3{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-3{stroke:hsl(300, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-3{stroke-width:5;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-3 line{stroke:hsl(120, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-4 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-4 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-4 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-4 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-4 path{fill:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-4 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-4{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-4{stroke:hsl(330, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-4{stroke-width:2;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-4 line{stroke:hsl(150, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-5 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-5 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-5 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-5 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-5 path{fill:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-5 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-5{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-5{stroke:hsl(0, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-5{stroke-width:-1;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-5 line{stroke:hsl(180, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-6 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-6 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-6 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-6 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-6 path{fill:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-6 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-6{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-6{stroke:hsl(30, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-6{stroke-width:-4;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-6 line{stroke:hsl(210, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-7 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-7 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-7 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-7 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-7 path{fill:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-7 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-7{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-7{stroke:hsl(90, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-7{stroke-width:-7;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-7 line{stroke:hsl(270, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-8 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-8 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-8 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-8 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-8 path{fill:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-8 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-8{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-8{stroke:hsl(150, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-8{stroke-width:-10;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-8 line{stroke:hsl(330, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-9 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-9 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-9 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-9 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-9 path{fill:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-9 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-9{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-9{stroke:hsl(180, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-9{stroke-width:-13;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-9 line{stroke:hsl(0, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-10 rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-10 path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-10 circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-10 polygon,#mermaid-svg-HlXMHdSC3FEoJnpR .section-10 path{fill:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-10 text{fill:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .node-icon-10{font-size:40px;color:black;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-edge-10{stroke:hsl(210, 100%, 76.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .edge-depth-10{stroke-width:-16;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-10 line{stroke:hsl(30, 100%, 86.2745098039%);stroke-width:3;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled circle,#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:lightgray;}#mermaid-svg-HlXMHdSC3FEoJnpR .disabled text{fill:#efefef;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-root rect,#mermaid-svg-HlXMHdSC3FEoJnpR .section-root path,#mermaid-svg-HlXMHdSC3FEoJnpR .section-root circle,#mermaid-svg-HlXMHdSC3FEoJnpR .section-root polygon{fill:hsl(240, 100%, 46.2745098039%);}#mermaid-svg-HlXMHdSC3FEoJnpR .section-root text{fill:#ffffff;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-root span{color:#ffffff;}#mermaid-svg-HlXMHdSC3FEoJnpR .section-2 span{color:#ffffff;}#mermaid-svg-HlXMHdSC3FEoJnpR .icon-container{height:100%;display:flex;justify-content:center;align-items:center;}#mermaid-svg-HlXMHdSC3FEoJnpR .edge{fill:none;}#mermaid-svg-HlXMHdSC3FEoJnpR .mindmap-node-label{dy:1em;alignment-baseline:middle;text-anchor:middle;dominant-baseline:middle;text-align:center;}#mermaid-svg-HlXMHdSC3FEoJnpR :root{–mermaid-font-family:\”trebuchet ms\”,verdana,arial,sans-serif;}

架构风格分类

数据流风格

批处理序列

管道/过滤器

调用/返回风格

主程序/子程序

面向对象

层次结构

独立构件风格

进程通信

事件系统

虚拟机风格

解释器

基于规则的系统

仓库风格

数据库系统

超文本系统

黑板系统

C2风格

构件-连接件

异步消息

4.1 管道/过滤器

每个构件读取输入流,处理后输出到下一个。

优点:高内聚低耦合、支持重用、支持并行执行。 缺点:批处理结构、不适合交互应用、性能下降。

典型应用:UNIX Shell脚本、传统编译器。

4.2 面向对象风格

对象隐藏内部表示,通过过程调用交互。

优点:改变表示不影响其他对象。 缺点:需要知道对象标识,修改标识会影响所有调用者。

4.3 基于事件的隐式调用

构件触发/广播事件,系统自动调用注册的过程。

优点:支持重用,方便替换构件。 缺点:失去计算控制权,数据交换问题,正确性推理困难。

4.4 分层系统

每层为上层服务,作为下层客户,仅相邻层可见。

优点:抽象递增、功能增强、支持重用。 缺点:不是所有系统都能分层,难以找到合适抽象层次。

4.5 仓库风格(黑板系统)

中央数据结构保存当前状态,独立构件在其上执行。

黑板系统三部分:知识源、黑板数据结构、控制。

典型应用:语音识别、模式识别、松耦合代理数据共享。

4.6 C2风格

通过连接件绑定的并行构件网络。

规则:构件和连接件都有顶部和底部;构件之间不能直接连接;连接件之间通过底部到顶部连接。

特点:构件独立,异步消息通信,依赖性低。


5. 软件架构的4种建模方法

根据建模侧重点不同,分为4种模型(常考选择题):

模型侧重点关键特征
结构模型 构件、连接件、配置 使用架构描述语言(ADL)
框架模型 整体结构,不过分关注细节 针对特定问题
动态模型 大颗粒行为、系统演化 激励型,补充结构/框架模型
过程模型 构造步骤和过程 遵循过程脚本的结果

💡 真题直击:(1)是对结构或框架模型的补充 → 动态模型 (2)是研究构造系统的步骤和过程 → 过程模型


6. “4+1”视图模型

由Kruchten提出,从5个角度描述软件架构: 在这里插入图片描述

视图性质关注点
逻辑视图 静态 功能需求、类、对象
开发视图 静态 模块划分、代码组织
进程视图 动态 并发、性能、可用性
物理视图 动态 部署、硬件拓扑
场景 粘合剂 用例、交互序列

7. 架构风格适用场景速查表(高频考点)

架构风格典型应用场景
管道-过滤器 编译器、UNIX脚本
主程序/子程序、面向对象 组件内部设计
虚拟机(解释器/规则系统) 解释器、专家系统
C/S、B/S 分布式数据处理
平台/插件(微核) 支持插件扩展的应用(Eclipse、IDE)
MVC 用户交互程序设计
SOA 企业集成
C2 GUI软件开发(灵活可扩展)
事件驱动 推送系统、新闻订阅、松散耦合异步系统

📌 真题示例: “用于GUI软件开发,构建灵活可扩展应用系统” → C2风格 “用于对组件内部进行设计” → 面向对象风格


8. 经典真题演练

【例1】 软件架构风格是描述某一特定应用领域中系统组织方式的惯用模式。一个体系结构定义了一个词汇表和一组( )。架构风格反映领域中众多系统所共有的结构和( )。

A. 约束 B. 连接件 C. 拓扑结构 D. 规则 A. 语义特征 B. 功能需求 C. 质量属性 D. 业务规则

答案:A、A (词汇表+约束;结构和语义特征)


【例2】 某公司拟开发一个新闻系统,可根据用户注册兴趣推送新闻,应该采用( )架构风格?

A. 事件驱动系统 B. 主程序-子程序 C. 黑板 D. 管道-过滤器

答案:A(事件驱动,隐式调用推送)


【例3】 某编译器包括词法分析、语法分析、语义分析、代码生成四个阶段,每个阶段结果作为下一阶段输入且需独立存储,应采用( )架构风格?

A. 管道-过滤器 B. 数据仓储 C. 主程序-子程序 D. 解释器

答案:A(数据流通过管道传递,每个过滤器独立存储)


【例4】 不属于微服务架构三种实现模式的是( )

A. RESTful API模式 B. RESTful应用模式 C. 集中消息模式 D. 分布式消息模式

答案:D


本文内容根据购买课程讲义及官方教程整理,仅供学习参考。

赞(0)
未经允许不得转载:171主机测评 » 2、绪论与软件架构概述
分享到: 更多 (0)

评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址