COMP5349 Cloud Computing · 从会背到会做题

把云计算知识学成一套可输出的方法

这个页面根据你的《COMP5349 期末复习总结》和课件资料整理。目标不是把所有内容再堆一遍,而是教你按“概念图 → 对比表 → 场景题输出 → 主动回忆”的顺序真正掌握。

1. 这门课应该怎么学

每个知识点都按同一套流程处理,避免只背定义。

核心学习法
1

先问“它解决什么问题”

比如 SQS 不是“一个队列”,而是用异步消息把生产者和消费者解耦;NAT Gateway 不是“网络组件”,而是让私有子网单向出网。

2

再做“对比记忆”

考试喜欢问相似概念:Multi-AZ vs Read Replica、ALB vs NLB、Versioning vs Replication、Container vs VM。必须背差异,不只背定义。

3

最后练“链路输出”

场景题要写出顺序:请求从哪里来、经过什么服务、需要哪条路由/权限/安全组规则、失败时谁接管。

2. 知识地图

按考试高频程度组织。每张卡片都包含“学会的标准”。

按主题学习

Virtualization & EC2

重点是从传统 Hypervisor 学到 AWS Nitro 为什么更快、更安全。

NitroXenInstance Store
  • 能解释 Type 1/Type 2 Hypervisor、Dom0、KVM/QEMU/libvirt。
  • 能说清 Nitro Hypervisor、Nitro Cards、Security Chip 分工。
  • 能区分 EBS 持久存储和 Instance Store 临时存储。

S3 & Storage

重点是版本控制、冗余、复制和删除行为。

VersioningCRRLifecycle
  • 能解释 Object、Bucket、Key prefix、11 个 9 的含义。
  • 能回答 delete marker 是否复制、指定 Version ID 删除是否复制。
  • 能根据访问频率选择 Standard、IA、One Zone-IA、Glacier。

VPC & Network

重点是三层架构、路由表、公有/私有子网、SG 来源写法。

SubnetIGW/NATSG
  • 能画出 Public Web、Private App、Private DB 三层网络。
  • 能写出 IGW 和 NAT Gateway 的作用与路由目标。
  • 能解释为什么 SG source 用另一个 SG 比 CIDR 更好。

IAM & Security

重点是权限判断流程和服务间调用的权限放在哪里。

RolePolicySTS
  • 能背出默认 Deny、Explicit Deny、Explicit Allow 的顺序。
  • 能区分 Identity-based policy 和 Resource-based policy。
  • 能解释 EC2 Instance Profile、Lambda Execution Role、SQS Queue Policy。

RDS & Aurora

重点是托管数据库的责任边界和 Aurora 的存储层创新。

Multi-AZRead ReplicaVDL
  • 能比较 Multi-AZ 是高可用,Read Replica 是读扩展。
  • 能说出 Aurora 10GB segment、6 副本、3 AZ、W=4/R=3。
  • 能根据 VCL/CPL 推出 VDL,并说明哪些 log 会被 truncate。

ALB & ASG

重点是弹性伸缩、健康检查和请求分发算法。

Target TrackingLORHealth Check
  • 能解释 CloudWatch metric 如何触发 ASG 扩容。
  • 能写出 ALB 停止转发、ASG 替换实例的故障顺序。
  • 能说明请求处理时间差异大时为什么选 LOR。

Container / Serverless / K8s

重点是从 VM 到 Container,再到 Lambda MicroVM 与 K8s 编排。

NamespaceFirecrackerPod
  • 能比较 VM、Container、MicroVM 的隔离强度和资源开销。
  • 能解释 Lambda Execution Role 和 Resource Policy 的区别。
  • 能把 ECS Task/Service 映射到 K8s Pod/Deployment。

SQS & SNS

重点是异步解耦、Fan-out 和消息失败后的生命周期。

Visibility TimeoutDLQFan-out
  • 能讲清消息 Receive 后为什么变 Invisible。
  • 能解释 Consumer crash 后消息如何重新被消费。
  • 能写出 S3→SNS→SQS→EC2→S3 的 5 步权限链。

3. 逐章精讲:按这个标准学才算会

每一章都按“先理解问题、再背定义、再练输出”的顺序学。下面的绿色框就是你考试可以直接改写的答案。

精讲模式
0. 云计算基础:先建立整门课的坐标系

你要先解决的问题

云计算不是“把服务器放到别人那里”,而是把计算、存储、网络这些资源做成可按需申请、可弹性扩缩、按使用付费的服务。后面所有 AWS 服务都在回答同一个问题:某个 IT resource 应该由谁管理,用户还负责什么。

三种 Service Model

  • IaaS:AWS 给 VM、网络、存储;你管 OS、runtime、app、data。例:EC2。
  • PaaS:AWS 管 OS/runtime/middleware;你管 app code 和 data。例:Elastic Beanstalk。
  • SaaS:云厂商几乎全管;你只使用软件。例:Gmail、Salesforce。

Global / Regional / Zonal 怎么背

  • Global:不属于某一个 Region,如 IAM、Route53、CloudFront。
  • Regional:创建时选 Region,如 VPC、S3、RDS、ALB、ASG、SQS、SNS。
  • Zonal:绑定某个 AZ,如 EC2、EBS、Subnet、single-AZ RDS。

考试答题句式

Cloud computing provides ubiquitous, on-demand network access to a shared pool of configurable computing resources. AWS organizes infrastructure as Regions, Availability Zones, and data centers. A Region is geographically isolated, while an AZ is an independent failure domain inside a Region.

1. Virtualization & EC2:从 Hypervisor 学到 Nitro

先理解:虚拟化到底在解决什么

一台物理机如果只跑一个系统,资源会浪费;如果让多个 VM 共享同一硬件,又必须保证彼此隔离。Hypervisor 就是夹在硬件和 VM 之间的控制层,负责分配 CPU、内存、磁盘、网络,并阻止一个 VM 看到或影响另一个 VM。

Type 1 vs Type 2

  • Type 1 / Bare-metal:直接跑在硬件上,性能高,企业生产常用。例:VMware ESX。
  • Type 2 / Hosted:跑在 Host OS 上,本质像一个应用,适合开发测试。例:VMware GSX。

Xen、Hyper-V、KVM 怎么记

  • Xen:有 Domain 0,Dom0 是特权 VM,负责 I/O 和管理其他 Guest Domain。
  • Hyper-V:Root Partition 类似 Dom0,Child Partition 是用户 VM。
  • KVM:把 Linux kernel 变成 hypervisor;QEMU 做硬件仿真;libvirt 做管理。

Nitro 标准答案

AWS Nitro System consists of the Nitro Hypervisor, Nitro Cards, and a Nitro Security Chip. The Nitro Hypervisor is lightweight and purpose-built; it only handles CPU and memory partitioning and scheduling. Network, storage, instance management, monitoring, and security are offloaded to Nitro Cards. Therefore AWS no longer needs a Dom0, reducing attack surface and giving near bare-metal performance.

易错点

  • 裸金属实例用 Nitro Cards,但不用 Nitro Hypervisor。
  • Instance Store 是本地临时盘,stop/terminate 或宿主机故障会丢数据。
  • EBS 是网络挂载、同 AZ 内可挂载、数据独立于 EC2 生命周期。

你要会做的题

如果题目问“批处理临时数据,硬件故障后数据全丢是什么存储”,答 Instance Store。如果问“备份已配置 EC2 以便批量启动相同实例”,答 Create AMI。

2. S3 & Storage:把版本、复制、删除行为讲清楚

S3 的基本模型

S3 是 object storage。Object = key + metadata + content;Bucket 是 object 容器,bucket name 全局唯一。S3 没有真正文件夹,所谓 folder 是 key prefix 模拟出来的。

Redundancy / Versioning / Replication

  • Redundancy:默认机制,同 Region 多 AZ 存副本,防硬件故障,用户不需要配置。
  • Versioning:同一个 key 保存多个版本,防误删和误覆盖,需要额外存储费。
  • Replication:把对象复制到另一个 bucket,可同 Region 或跨 Region;CRR 两边 bucket 都必须开启 versioning。

Versioning 删除题标准答案

If an object is deleted without specifying a version ID in a version-enabled bucket, S3 creates a delete marker with the same key. The previous versions remain stored. The delete marker becomes the current version, so normal GET returns 404. Removing the delete marker restores access to the previous version.

CRR 删除行为必须精确

  • 不指定 Version ID 删除:源桶加 delete marker;默认不复制到目标桶,除非开启 Delete Marker Replication。
  • 指定 Version ID 删除:只永久删除源桶那个版本;不会同步删除目标桶版本。
  • 这样设计是为了防止恶意或误删跨 Region 传播。

Storage Class 选择

  • 频繁访问:S3 Standard。
  • 访问模式不可预测:Intelligent-Tiering。
  • 少访问但仍需快速取回:Standard-IA。
  • 可接受单 AZ 风险来省钱:One Zone-IA。
  • 归档:Glacier Instant / Flexible / Deep Archive,越便宜取回越慢。

考前自测

问自己:上传 report.csv 三次后,不指定版本删除一次,源桶里有什么?目标桶里有什么?怎么恢复?如果你能闭卷讲出这三问,就算掌握 S3 版本题。

3. VPC & Security Group:按流量方向学网络

先记层级

VPC 是 Region 级逻辑隔离网络;Subnet 是 AZ 级,不能跨 AZ;CIDR 创建后不可改,Subnet CIDR 不能重叠。每个 subnet 还会保留 5 个 IP:network、VPC router、DNS、reserved、broadcast。

Public 和 Private 的本质

Public subnet 不是因为名字叫 public,而是它关联的 route table 有 0.0.0.0/0 → IGW,并且实例有 public IP。Private subnet 没有直接到 IGW 的默认路由,出网通常走 NAT Gateway。

三层 VPC 题答题顺序

  1. 创建一个 VPC,例如 10.0.0.0/16,跨多个 AZ。
  2. 每个 AZ 建 public web subnet、private app subnet、private db subnet。
  3. Public route table 加 0.0.0.0/0 → IGW,给 ALB 或 Web 层接 Internet。
  4. Private app subnet 如果要出网更新软件,加 0.0.0.0/0 → NAT Gateway
  5. DB subnet 不直接暴露 Internet,只允许 App SG 访问数据库端口。

Security Group 怎么写最像标准答案

  • SG 是实例级、stateful、只写 allow,没有 deny。
  • 默认 inbound 全拒绝,outbound 全允许。
  • Source 用 CIDR 是基于 IP,范围粗;Source 用另一个 SG 是基于逻辑身份,跨 AZ 仍生效,资源增减时不用改规则。

易错点

  • NAT Gateway 必须放在 public subnet,并绑定 Elastic IP。
  • IGW 是 VPC 级,一个 VPC 只能 attach 一个 IGW。
  • Subnet 能不能访问 Internet,看 route table,不看它名字。

你必须会画的流量

Client → Internet → IGW → Public route table → ALB/Web SG inbound 80/443 → App SG inbound source = ALB/Web SG → DB SG inbound source = App SG。

4. IAM & Security:权限题按“身份、动作、资源、条件”拆

四个 IAM 核心对象

  • User:长期身份,有 console password 或 access key。
  • Group:User 集合,不能嵌套,不能直接登录。
  • Policy:JSON 权限文档,声明允许/拒绝什么。
  • Role:被 assume 后获得临时凭证,由 STS 生成 access key、secret key、session token 和过期时间。

权限判断流程

Start with default deny. If any applicable policy contains an explicit deny, the request is denied immediately. Otherwise, AWS checks whether there is an explicit allow. If there is an allow, the request is allowed; if not, it remains implicitly denied.

Explicit Deny > Explicit Allow > Default/Implicit Deny

Identity-based vs Resource-based

  • Identity-based policy:贴在 User/Group/Role 上,回答“我能访问什么”。
  • Resource-based policy:贴在资源上,带 Principal,回答“谁能访问我”。S3 bucket policy、SNS topic policy、SQS queue policy 都是这种。

Policy JSON 分析模板

  1. 看 Effect:Allow 还是 Deny,有 Deny 就优先。
  2. 看 Action:列了哪些 API,没列的 API 默认不允许。
  3. 看 Resource:ARN 是否匹配,S3 bucket 和 object ARN 经常要分开写。
  4. 看 Condition:IP、Tag、prefix、source ARN 等限制是否满足。

S3 ARN 易错

arn:aws:s3:::my-bucket 是 bucket 本身,用于 ListBucket 等 bucket-level action;arn:aws:s3:::my-bucket/* 是 bucket 里的 objects,用于 GetObject/PutObject/DeleteObject。

服务间权限放哪里

  • EC2 app 访问 S3/SQS:权限放 EC2 role,经 Instance Profile 附到实例。
  • S3 调 SNS:权限放 SNS topic resource policy,Principal 是 s3.amazonaws.com
  • SNS 调 SQS:权限放 SQS queue resource policy,Principal 是 sns.amazonaws.com
  • Lambda 访问 S3:权限放 Lambda execution role;谁能调用 Lambda 放 resource-based policy。
5. RDS & Aurora:数据库题要分清 HA、读扩展和存储层

RDS 托管到哪里

RDS 是 managed relational database。AWS 管底层硬件、数据库软件安装、补丁、备份、主机故障替换;你仍然要管 schema、查询、索引、访问控制、扩缩容选择和应用连接。

Multi-AZ vs Read Replica

  • Multi-AZ:目标是 HA 和 durability;同步复制;Primary + Standby;故障时自动 failover;standby 不服务读请求。
  • Read Replica:目标是读扩展;异步复制;可有多个 replica;主要处理 read-heavy workload;不默认自动 failover。

Aurora 架构标准答案

Aurora separates compute from storage. Data is divided into 10 GB segments. Each segment has six copies across three AZs, two copies per AZ. Aurora uses quorum: a write succeeds after 4 of 6 acknowledgements, and a read needs 3 of 6. The primary sends redo log records to the storage layer; storage nodes materialize data pages independently. This is why Aurora is often described as “log is the database”.

Quorum 题怎么做

  • 正常:6 份。
  • 丢 1 个 AZ:少 2 份,剩 4 份,仍满足 W=4,所以写可用。
  • 丢 1 个 AZ 再丢 1 个节点:剩 3 份,满足 R=3,但不满足 W=4,所以读可用,写暂停。

VDL 题公式

LSN 单调递增;VCL 是存储层连续收到的最高 LSN;CPL 是数据库声明的事务一致点;VDL 是小于等于 VCL 的最高 CPL。

VCL=1007, CPL=900/1000/1100 → VDL=1000 → truncate 1001-1007

易错点

不要说 Aurora 数据存在 DB instance 的 EBS 上。Aurora 的关键创新就是计算和存储分离,数据在共享分布式 storage layer。

6. Elasticity、ALB、ASG:按监控到替换的时序讲

Scalability vs Elasticity

Scalability 是系统处理增长工作负载的能力;Elasticity 是云环境里根据需求自动、细粒度地扩容和缩容。垂直扩展是升级单机规格,水平扩展是增加机器数量。

ASG 四个核心配置

  • Capacity:Min / Desired / Max。
  • Launch Template:AMI、instance type、SG、user data。
  • Load Balancer:新实例自动注册到 target group。
  • Scaling Mechanism:scheduled、target tracking、step、simple。

CPU 升高扩容题标准答案

CloudWatch collects CPU utilization metrics. When the metric exceeds the target threshold, an alarm or target tracking policy triggers the Auto Scaling Group. The ASG launches new EC2 instances from the launch template, registers them with the ALB target group, and the ALB starts distributing traffic to healthy targets.

ALB / NLB / GLB / CLB

  • ALB:Layer 7,HTTP/HTTPS,适合 Web 应用。
  • NLB:Layer 4,TCP/UDP/TLS,低延迟、高吞吐、静态 IP。
  • GLB:Layer 3,给第三方安全设备等网络虚拟设备用。
  • CLB:旧服务,主要历史兼容。

健康检查替换顺序

  1. Target Group 定期做 HTTP health check。
  2. 实例异常,ALB 标记 unhealthy。
  3. ALB 停止把新请求发给它。
  4. ASG 使用 ELB health check 后确认实例 unhealthy。
  5. ASG terminate 旧实例。
  6. ASG 按 launch template 启新实例。
  7. 新实例通过 health check 后,ALB 恢复分流。

算法易错

Round-robin 只是轮流发请求,不知道每个请求处理多久。请求耗时差异大时选 LOR,因为它看每个目标当前 outstanding requests 数量。

7. CloudFormation & DevOps:看懂 IaC 和流水线题

IaC 为什么重要

Infrastructure as Code 把基础设施写成模板,带来 repeatability、reusability、maintainability。同一份 template 可以创建多个 stack,减少手工点控制台带来的不一致。

CloudFormation Template 必背

  • Resources 是唯一必填 section。
  • Parameters 传差异化值,如 instance type。
  • Mappings 做静态映射,常见是不同 Region 对应不同 AMI。
  • Outputs 可以 Export 给其他 Stack 引用。

Intrinsic Functions

  • !Ref:返回物理 ID 或资源默认返回值。
  • !GetAtt:返回资源属性,如 EC2 PublicIp、RDS Endpoint。
  • !FindInMap:从 Mapping 里查值。
  • !If / !Equals:用于条件逻辑。

Debug 题答法

Use CloudFormation stack events or describe-stack-events to find the failed resource and ResourceStatusReason. Use validate-template to catch syntax problems. For updates, create a change set first to preview what resources will be changed.

CodePipeline 层级

Pipeline → Stage → Action → Artifact。Source 取代码,CodeBuild 构建测试,CodePipeline 负责编排但不亲自 build/deploy,Deploy 可以交给 CodeDeploy 或 CloudFormation。

CI/CD 易错

Continuous Delivery 是自动到可发布状态或 repository,生产部署通常需要人工审批;Continuous Deployment 是测试通过后自动部署到生产。

8. Container、Lambda、Kubernetes:现代应用要用“隔离强度”串起来

VM vs Container vs MicroVM

  • VM:每个 VM 有独立 guest OS,隔离强,但资源开销大。
  • Container:共享宿主机内核,靠 namespace 隔离视图,靠 cgroup 限制资源,轻量但隔离弱于 VM。
  • MicroVM:介于二者之间,Lambda 用 Firecracker,兼顾较强隔离和低开销。

Docker 必背

  • Image 是只读模板,多层只读 layer 可共享。
  • Container 是 image 的运行实例,启动时加一层薄的 writable layer。
  • 容器删除后 writable layer 消失;持久化用 volume、bind mount 或 tmpfs。
  • Bridge 网络默认通过虚拟网桥和 NAT 出网。

Lambda 权限标准答案

Lambda has two permission directions. A resource-based policy controls who can invoke the function, such as S3, EventBridge, API Gateway, or SNS. The execution role controls what the function can access while running, such as S3, DynamoDB, SQS, CloudWatch Logs, or Secrets Manager.

Lambda 反模式

  • Lambda Monolith:一个函数塞太多逻辑,冷启动和维护成本升高。
  • Recursive Pattern:写 S3 又被同一个 S3 event 触发,可能无限循环计费。
  • Lambda 调 Lambda:同步链式等待,等待也计费,错误处理复杂。
  • Synchronous Waiting:长时间同步等任务,违背短暂、事件驱动思想。

Kubernetes 结构

  • Control Plane:API Server 是入口,Scheduler 负责调度,Controller Manager 维持期望状态,etcd 存配置。
  • Worker Node:Kubelet 管本节点容器,Kube-proxy 管网络规则,Container Runtime 跑容器。
  • Pod 是最小调度单元,同 Pod 内容器共享网络 namespace 和 Pod IP。
  • Deployment 管副本和滚动更新;Service 提供稳定入口;Ingress 管外部 HTTP/HTTPS 路由。

ECS 到 K8s 映射

ECS Task ≈ Kubernetes Pod;ECS Service ≈ Deployment;Task Definition ≈ Pod Template;ALB Target Group / ECS service discovery 的稳定访问能力 ≈ Kubernetes Service。

9. SQS & SNS:场景题最重要的是消息生命周期和权限链

SQS vs SNS

  • SQS:Queue,point-to-point,consumer pull,一条消息通常被一个 consumer 处理。
  • SNS:Topic,pub/sub,push,一条消息广播给多个 subscriber。
  • Fan-out:SNS 后面接多个 SQS queue,每个下游拿到独立副本,可独立扩缩和失败重试。

SQS 生命周期标准答案

  1. Producer sends a message; the message is stored and visible.
  2. Consumer calls ReceiveMessage; the message becomes invisible for the visibility timeout.
  3. If processing succeeds, the consumer must call DeleteMessage.
  4. If the consumer crashes or does not delete it before timeout, the message becomes visible again and may be processed again.
  5. After too many failed receives, the message can be moved to a dead-letter queue.

Standard vs FIFO

  • Standard:高吞吐,at-least-once delivery,best-effort ordering,可能重复或乱序。
  • FIFO:严格保序,exactly-once processing,适合金融交易等顺序敏感任务。

Visibility Timeout 易错

Visibility timeout 不是消息保留期,也不是处理时间上限。它只是“别人暂时看不到这条消息”的时间。必须设置得长于正常处理时间,并让处理逻辑幂等,因为 Standard Queue 可能重复投递。

S3 → SNS → SQS → EC2 → S3 五步权限链

  1. Client 上传文件到 S3:给用户或应用角色 s3:PutObject
  2. S3 event 发到 SNS:在 SNS Topic resource policy 允许 Principal s3.amazonaws.com 执行 sns:Publish,并用 SourceArn 限定源 bucket。
  3. SNS 投递到 SQS:在 SQS Queue resource policy 允许 Principal sns.amazonaws.com 执行 sqs:SendMessage,并用 SourceArn 限定源 topic。
  4. EC2 worker 消费 SQS:EC2 Instance Profile 的 role 需要 sqs:ReceiveMessagesqs:DeleteMessagesqs:GetQueueAttributes
  5. EC2 worker 读写 S3:同一个 role 需要 s3:GetObjects3:PutObject

4. 中英文对照速背

左边帮你理解,右边帮你写英文答案。考试时不用逐字背,但要能保留这些关键词和逻辑顺序。

Bilingual

云计算基础

云计算的核心不是“租服务器”,而是通过网络按需访问共享的、可配置的计算资源池。你要知道资源责任边界:IaaS 用户管 OS 及以上,PaaS 用户主要管代码和数据,SaaS 用户只使用软件。

关键词:按需访问、共享资源池、可配置、IaaS/PaaS/SaaS、Region、AZ、Data Center

Cloud Computing Basics

Cloud computing provides on-demand network access to a shared pool of configurable computing resources. In IaaS, the customer manages the OS and above. In PaaS, the customer mainly manages application code and data. In SaaS, the provider manages almost the entire stack.

Keywords: on-demand access, shared pool, configurable resources, IaaS, PaaS, SaaS, Region, Availability Zone

Virtualization / EC2 / Nitro

虚拟化让多个 VM 共享同一台物理机,同时通过 Hypervisor 保证资源分配和隔离。Nitro 的重点是把传统 hypervisor 的很多工作卸载到专用硬件卡,所以不再需要 Xen 的 Dom0,攻击面更小,性能接近裸机。

  • Nitro Hypervisor:只管 CPU 和内存分区、调度。
  • Nitro Cards:卸载网络、存储、管理、监控、安全。
  • Security Chip:硬件级信任根。

Virtualization / EC2 / Nitro

Virtualization allows multiple VMs to share the same physical host while the hypervisor allocates resources and enforces isolation. AWS Nitro offloads networking, storage, management, monitoring, and security to dedicated hardware, so it no longer needs a privileged Dom0.

  • The Nitro Hypervisor handles CPU and memory partitioning and scheduling.
  • Nitro Cards offload I/O and management functions.
  • The Nitro Security Chip provides a hardware root of trust.

S3 / Versioning / CRR

S3 是对象存储,Object 由 key、metadata、content 组成。Versioning 用来防误删和覆盖;不指定版本删除时不会真正删旧数据,而是加 delete marker。CRR 是跨区域复制,源桶和目标桶都必须开 versioning。

  • 删除 marker 默认不复制,除非开启 Delete Marker Replication。
  • 指定 Version ID 删除不会复制到目标桶。
  • 11 个 9 是 durability,不是 availability。

S3 / Versioning / CRR

S3 is object storage. An object consists of a key, metadata, and content. Versioning protects against accidental deletion and overwrite. If an object is deleted without a version ID, S3 creates a delete marker instead of deleting previous versions. Cross-Region Replication requires versioning on both buckets.

  • Delete markers are not replicated by default.
  • Deleting a specific version is not replicated.
  • Eleven nines refers to durability, not availability.

VPC / Subnet / Security Group

VPC 是 Region 级隔离网络,Subnet 是 AZ 级。Public subnet 的本质是路由表有 0.0.0.0/0 → IGW;Private subnet 通常通过 NAT Gateway 单向出网。Security Group 是实例级、stateful、只有 allow 没有 deny。

  • Web 层放 public subnet,App/DB 层放 private subnet。
  • App 出网走 NAT Gateway;DB 不直接出网。
  • SG source 用另一个 SG 比 CIDR 更精确。

VPC / Subnet / Security Group

A VPC is a regional isolated network, while a subnet is scoped to one Availability Zone. A public subnet is public because its route table has a default route to an Internet Gateway. Private subnets usually use a NAT Gateway for outbound Internet access. Security Groups are instance-level, stateful, and allow-only.

  • Place the web tier in public subnets and app/database tiers in private subnets.
  • Use NAT Gateway for outbound traffic from private app subnets.
  • Using a Security Group as the source is more precise than using a CIDR range.

IAM / Policy / Role

IAM 题要按身份、动作、资源、条件来拆。权限判断顺序是:默认 Deny;如果有 Explicit Deny,直接 Deny;否则看有没有 Explicit Allow;没有 Allow 就是 Implicit Deny。

  • Identity-based policy:贴在 User/Group/Role 上,回答“我能访问什么”。
  • Resource-based policy:贴在资源上,带 Principal,回答“谁能访问我”。
  • Role 通过 STS 获得临时凭证。

IAM / Policy / Role

For IAM policy questions, analyze the identity, action, resource, and condition. Authorization starts with default deny. An explicit deny overrides everything. If there is no explicit deny, AWS checks for an explicit allow. Without an allow, the request is implicitly denied.

  • Identity-based policies answer “what can this identity access?”
  • Resource-based policies answer “who can access this resource?”
  • Roles provide temporary credentials through STS.

RDS / Aurora

RDS 是托管关系数据库,AWS 管硬件、补丁、备份、故障替换。Multi-AZ 解决高可用,Read Replica 解决读扩展。Aurora 的核心创新是计算和存储分离,数据切成 10GB segments,每段 6 份,跨 3 AZ。

  • Write quorum = 4/6,Read quorum = 3/6。
  • 丢 1 个 AZ 还剩 4 份,所以仍可写。
  • VDL 是小于等于 VCL 的最高 CPL。

RDS / Aurora

RDS is a managed relational database service. AWS manages hardware, patching, backups, and host replacement. Multi-AZ is for high availability, while Read Replicas are for read scaling. Aurora separates compute from storage. Data is split into 10 GB segments, with six copies across three AZs.

  • Write quorum is 4 out of 6, and read quorum is 3 out of 6.
  • Losing one AZ leaves four copies, so writes can continue.
  • VDL is the highest CPL that is less than or equal to VCL.

CloudWatch / ASG / ALB

弹性题按时序写:CloudWatch 收集指标,Alarm 或 Target Tracking 触发 ASG,ASG 用 Launch Template 启新 EC2,实例注册进 ALB Target Group,健康检查通过后 ALB 开始分流。

  • ALB 是 Layer 7,适合 HTTP/HTTPS。
  • 请求处理时间差异大时选 LOR。
  • 实例 unhealthy 后 ALB 先停转发,ASG 再替换。

CloudWatch / ASG / ALB

For elasticity questions, describe the sequence: CloudWatch collects metrics; an alarm or target tracking policy triggers the Auto Scaling Group; the ASG launches new EC2 instances from the launch template; the instances are registered with the ALB target group; after health checks pass, the ALB distributes traffic to them.

  • ALB is Layer 7 and is suitable for HTTP/HTTPS applications.
  • Use Least Outstanding Requests when request processing times vary.
  • ALB stops forwarding to unhealthy targets before ASG replaces them.

CloudFormation / DevOps

CloudFormation 是 AWS 原生 IaC。Template 像类,Stack 像对象。Resources 是唯一必填 section。CodePipeline 是编排服务,层级是 Pipeline → Stage → Action → Artifact。

  • !Ref 返回物理 ID 或默认值。
  • !GetAtt 返回资源属性。
  • Change Set 用来预览更新影响。

CloudFormation / DevOps

CloudFormation is AWS-native Infrastructure as Code. A template is like a class, and a stack is like an object. Resources is the only required section. CodePipeline is an orchestration service, organized as Pipeline → Stage → Action → Artifact.

  • !Ref returns a physical ID or the default return value.
  • !GetAtt returns a resource attribute.
  • A change set previews the impact of an update.

Container / Lambda / Kubernetes

Container 是 OS 级虚拟化,共享宿主内核,用 namespace 隔离视图,用 cgroup 限制资源。Lambda 是 serverless FaaS,适合事件驱动、低频或不可预测流量。Kubernetes 是容器编排系统,Pod 是最小调度单元。

  • VM 隔离强但重;Container 轻但隔离较弱;MicroVM 居中。
  • Execution Role 管 Lambda 能访问什么。
  • Resource-based Policy 管谁能调用 Lambda。

Container / Lambda / Kubernetes

Containers are OS-level virtualization. They share the host kernel, use namespaces for isolation, and cgroups for resource limits. Lambda is serverless FaaS and fits event-driven, low-duty-cycle, or unpredictable workloads. Kubernetes is a container orchestration system, and Pod is the smallest scheduling unit.

  • VMs provide strong isolation but are heavy; containers are lightweight but weaker; MicroVMs sit in between.
  • The execution role controls what a Lambda function can access.
  • The resource-based policy controls who can invoke the Lambda function.

SQS / SNS / Fan-out

SQS 是 point-to-point queue,consumer 主动 pull;SNS 是 pub/sub topic,主动 push 给多个 subscriber。Fan-out 用 SNS 广播到多个 SQS,每个下游拿到独立副本,可以独立扩缩、独立失败重试。

  • ReceiveMessage 后消息进入 Invisible 状态。
  • 处理成功必须 DeleteMessage。
  • 超时未删会重新 Visible,可能被重复消费;多次失败进 DLQ。

SQS / SNS / Fan-out

SQS is a point-to-point queue where consumers pull messages. SNS is a pub/sub topic that pushes messages to multiple subscribers. The fan-out pattern uses SNS to broadcast to multiple SQS queues, so each downstream service receives its own copy and can scale and retry independently.

  • After ReceiveMessage, the message becomes invisible.
  • After successful processing, the consumer must call DeleteMessage.
  • If the timeout expires before deletion, the message becomes visible again and may be processed again; repeated failures can move it to a DLQ.

5. 9 天学习计划

按 6 月 6 日到 6 月 15 日设计。每天都要有“输出任务”,不是只看笔记。

考前节奏
Day 1建地图

通读总结,建立全局结构

把 17 个章节压成 6 条主线:计算、存储、网络、安全、数据库、解耦/现代应用。

  • 画一张服务关系图:Client、ALB、EC2、S3、SNS、SQS、RDS。
  • 标出每个服务属于 Global、Regional 还是 Zonal。
Day 2计算

Virtualization、EC2、Nitro

从“为什么要虚拟化”学到“为什么 AWS Nitro 替代 Xen”。

  • 闭卷写出 Nitro 三组成和相比 Xen 的 3 个优势。
  • 用 5 句话解释 EBS vs Instance Store。
Day 3存储

S3、Versioning、CRR、Lifecycle

用“删除一个 report.csv 后发生什么”练习版本题。

  • 写出不指定 Version ID 删除、指定 Version ID 删除的区别。
  • 做 5 道 S3 MCQ,并把错题归类为概念错还是细节错。
Day 4网络

VPC、Subnet、Route Table、IGW、NAT、SG

这部分要边画图边学,否则很容易背散。

  • 画三层 VPC:2 AZ,每 AZ public/app/db 三个 subnet。
  • 写出 Web 入站、App 出网、DB 访问的 SG 和路由规则。
Day 5安全

IAM Identity、Policy、Role、Federation

重点训练 JSON policy 解释能力。

  • 拿一段 Policy,用中文写出允许什么、不允许什么、为什么。
  • 闭卷写出 EC2 访问 S3、S3 发 SNS、SNS 发 SQS 的权限放置位置。
Day 6数据库

RDS、Aurora、Multi-AZ、Read Replica

把托管责任和 HA/Scale 的目标分开。

  • 做一张 Multi-AZ vs Read Replica 对比表。
  • 练 3 个 VCL/CPL/VDL 计算题。
Day 7弹性

CloudWatch、ASG、ALB

按“监控 → 决策 → 新实例 → 注册 → 分流”的链路记。

  • 写出 CPU 80% 时 ASG 如何扩容。
  • 写出实例返回 500 时 ALB 和 ASG 的处理顺序。
Day 8现代应用

Container、Lambda、K8s、SQS/SNS

用“解耦”和“运行时隔离”串起来。

  • 比较 Container、Lambda、K8s 分别适合什么场景。
  • 完整写一遍 S3→SNS→SQS→EC2→S3 的消息和权限链。
Day 9模拟

整套闭卷输出

不要再补新资料,重点查漏补缺。

  • 限时做一套:20 MCQ + 4 个短答 + 2 个场景题。
  • 把错题按“定义、对比、链路、权限、故障时序”分类。

6. 场景题答题模板

场景题要让阅卷人看到你知道“谁调用谁、凭什么调用、失败后怎么办”。

拿分框架

VPC 三层架构

  • 先说明 VPC 是 Region 级,Subnet 是 AZ 级。
  • Public subnet 放 ALB/Bastion,route table 有 0.0.0.0/0 → IGW
  • Private app subnet 出网走 NAT Gateway,DB subnet 不直接出网。
  • SG 用逻辑来源:App inbound source = Web/ALB SG,DB inbound source = App SG。

IAM Policy 分析

  • 先找 Effect:是否有 Explicit Deny。
  • 再找 Action:允许哪些 API,不在列表里就是默认 Deny。
  • 再找 Resource:Bucket 操作和 Object 操作 ARN 是否写对。
  • 最后看 Condition:IP、Tag、Prefix 是否限制了权限。

SQS Visibility Timeout

  • Producer 发送消息,消息处于 Visible。
  • Consumer ReceiveMessage 后变 Invisible,开始 visibility timeout。
  • 处理成功必须 DeleteMessage;SQS 不会自动删除。
  • 若 crash 或超时未删,消息重新 Visible,可能被重复消费;多次失败进 DLQ。

S3 → SNS → SQS 权限链

  • Client 上传 S3:身份策略允许 s3:PutObject
  • S3 发布 SNS:SNS Topic resource policy 允许 s3.amazonaws.comsns:Publish
  • SNS 发 SQS:SQS Queue policy 允许 sns.amazonaws.comsqs:SendMessage
  • EC2 消费 SQS 和写 S3:权限放在 Instance Profile 对应的 IAM Role。

ALB + ASG 故障替换

  • ALB Target Group 做应用层 health check。
  • 目标异常后 ALB 立即停止转发请求。
  • ASG 根据 ELB health check 判定实例 unhealthy。
  • ASG terminate 旧实例,再按 Launch Template 启新实例并注册回 Target Group。

Aurora 可用性题

  • 先写 Aurora 存储层:10GB segment,6 copies across 3 AZs。
  • 写 quorum:write 需要 4,read 需要 3。
  • 丢 1 AZ 等于丢 2 份,还剩 4 份,所以写仍可用。
  • VDL 题:VDL 是小于等于 VCL 的最高 CPL,高于 VDL 的 log truncate。

7. 主动回忆卡片

点击卡片显示答案。先闭眼说一遍,再翻答案。

自测
Question

8. 考前检查表

全部勾完后,你应该已经能闭卷解释主要知识点。

自动保存

最后一天不要再犯这些错

  • 把 S3 durability 和 availability 混在一起。
  • 把 RDS Multi-AZ 写成读扩展,或把 Read Replica 写成自动 failover。
  • 忘记 SQS 消息处理成功后必须 DeleteMessage。
  • 把 Lambda “谁能调用我”和“我能访问什么”的权限放反。
  • VPC 题只写服务名,不写 route table、SG source 和流量方向。