Q1 · AWS Nitro System 6 分
Q: What is the AWS Nitro system and how does it improve virtualization? List two key features.
什么是 Nitro,它如何改进虚拟化?列两个关键特性。
什么是 Nitro,它如何改进虚拟化?列两个关键特性。
AWS Nitro is the system that runs EC2 today. It replaced the old Xen hypervisor. It moves most of the virtualization work onto special hardware. So almost all of the CPU and memory go to the customer's instance. This gives near bare-metal speed and a small attack surface.
Two key features:
Nitro是现在跑EC2的系统,取代了旧的Xen。它把大部分虚拟化工作搬到专用硬件上,几乎所有CPU/内存都给客户实例→性能接近裸机、攻击面小。两特性:①Nitro Hypervisor(极薄,只管CPU和内存);②Nitro卡(接管网络/存储/安全)。
- Nitro Hypervisor: a very thin and light hypervisor. It only handles CPU and memory. Everything else is moved off it, so it is fast and hard to attack.
- Nitro Cards: special hardware that takes over networking, storage and security from the main CPU.
Q2 · S3 Redundancy vs Versioning 6 分
Q: Compare S3 redundancy and versioning. What is the key difference in purpose and behavior?
对比 S3 冗余与版本控制,目的和行为上的关键区别?
对比 S3 冗余与版本控制,目的和行为上的关键区别?
Redundancy: S3 keeps several copies of each object in different AZs (Standard uses 3 or more). It is free and always on. It protects against hardware or AZ failure. The user does not set it up.
Versioning: you must turn it on, and it costs extra. Every change makes a new version. A delete only adds a delete marker; it does not really remove the data, so you can get old versions back. It protects against human mistakes (overwrite or delete).
Key difference: redundancy protects against hardware failure (free, automatic). Versioning protects against user mistakes by keeping old versions (paid, optional).
冗余:S3在不同AZ存多份(Standard≥3),免费、一直开,防硬件/AZ故障,用户不用配。版本控制:要手动开、额外收费,每次改建新版本,删除只加删除标记不真删,可找回旧版本,防人为误删/覆盖。关键区别:冗余防硬件故障(免费自动);版本控制防人为错误、留旧版本(付费可选)。
Q3 · RDS Multi-AZ vs Read Replica 6 分
Q: Describe the difference between RDS Multi-AZ and Read Replica.
描述 RDS Multi-AZ 与读副本的区别。
描述 RDS Multi-AZ 与读副本的区别。
Multi-AZ: keeps a standby copy in another AZ. It copies data synchronously (at the same time). It is for high availability and automatic failover. If the main one fails, AWS switches to the standby automatically. The standby cannot be read.
Read Replica: copies data asynchronously (a bit later). It is for read scaling — it takes read queries off the main database. It can be read, and you can promote it to a main database. RDS allows up to 5; Aurora up to 15.
Short: Multi-AZ = HA, synchronous, not readable, auto failover. Read Replica = read scaling, asynchronous, readable, no auto failover.
Multi-AZ:另一AZ热备,同步复制,用于高可用+自动故障转移,standby不可读。Read Replica:异步复制,用于读扩展、分担读查询,可读、可提升为主(RDS≤5,Aurora≤15)。简记:Multi-AZ保命(同步/不可读/自动切);Read Replica提速(异步/可读/不自动切)。
Q4 · Containers vs Serverless microservices 8 分
Q: Compare containers vs serverless for microservices. Give a use case where each is best.
对比用容器与无服务器做微服务,各举一个最适合的用例。
对比用容器与无服务器做微服务,各举一个最适合的用例。
Containers (ECS/EKS): the unit is a container (a Task in ECS, a Pod in EKS). A long-running service keeps a set number of copies. You manage the machines under it (or auto scale them). Good: full control, no time limit, can install anything; good for steady or long jobs. Bad: you manage images and capacity, and you pay while it runs.
Use case: a long-running API, or a video/PDF job that takes minutes and needs special libraries.
Use case: a long-running API, or a video/PDF job that takes minutes and needs special libraries.
Serverless (Lambda): the unit is a function. It scales automatically per request. You manage no servers. Good: near-zero cost when idle, auto scaling, less work. Bad: 15-minute limit, limited memory, cold start, must be stateless.
Use case: a spiky, low-frequency, event task — like making a thumbnail when an image is uploaded to S3.
容器(ECS/EKS):单元是容器(Task/Pod),长期服务维持几份副本,底层机器自己管/自动扩。优:完全掌控、无时限、可装任何东西,适合稳定/长任务;缺:要管镜像和容量、运行就花钱。用例:长跑的API,或耗时几分钟、需特殊库的视频/PDF处理。无服务器(Lambda):单元是函数,按请求自动扩,无需管服务器。优:空闲几乎零成本、自动扩、省事;缺:最长15分钟、内存有限、冷启动、要无状态。用例:突发/低频/事件型,如S3上传图片就生成缩略图。
Use case: a spiky, low-frequency, event task — like making a thumbnail when an image is uploaded to S3.
Q5 · IAM Policy 分析 8 分
Policy: Allow ec2:StartInstances/StopInstances on
*. Deny the same with Condition IpAddress: aws:SourceIp = 203.0.113.0/24.1. [2] What EC2 actions are affected?
Only ec2:StartInstances and ec2:StopInstances. Nothing else is allowed or denied.只有 StartInstances 和 StopInstances;其它都不涉及。
2. [2] User stops an instance from IP 203.0.113.17 — what happens?
Denied. 203.0.113.17 is inside 203.0.113.0/24, so the Deny matches. An explicit Deny always beats an Allow.拒绝。203.0.113.17在该网段内,Deny命中;显式Deny永远赢过Allow。
3. [2] Can the user start instances from IP 198.51.100.10?
Yes. 198.51.100.10 is not in 203.0.113.0/24, so the Deny does not match. Only the Allow applies.可以。该IP不在网段内,Deny不命中,只有Allow生效。
4. [2] Modify the policy so the deny applies to ALL IPs EXCEPT 198.73.100.0/24.
Change the condition from
把条件从 IpAddress 改成 NotIpAddress:{aws:SourceIp:198.73.100.0/24}。这样源IP不在该网段就拒绝,即只有该网段能启停实例。
IpAddress to NotIpAddress:
"Effect": "Deny",
"Action": ["ec2:StartInstances","ec2:StopInstances"],
"Resource": "*",
"Condition": {
"NotIpAddress": { "aws:SourceIp": "198.73.100.0/24" }
}
Now the Deny hits every IP that is not in 198.73.100.0/24. So only that range can start/stop instances.Q6 · Versioning + Replication (report.csv) 15 分
Setup: bucket
project has versioning + replication to project-backup (other region, default). Day1 upload = Version A; Day2 new version = Version B; Day3 deleted in Console.1. [3] How many versions in
project after Day3? List them.3 things: Version A, Version B, and a delete marker (added on Day 3, now the current version). The two real versions are still there.3个:Version A、Version B、一个删除标记(第3天加的,现在是当前版本);两个真实版本还在。
2. [3] Can you recover report.csv after Day3 in
project? How?Yes. Delete the delete marker (delete that version by its version ID). Then Version B becomes the current version again, and a normal GET returns Version B.能。删掉那个删除标记(按它的版本ID删),Version B就重新成为当前版本,普通GET能取回B。
3. [3] How many versions in
project-backup after Day3? List them.2 versions: Version A and Version B (both copied by replication). Version B is current. By default, delete markers are not copied, so the backup bucket has no delete marker.2个:Version A 和 Version B(复制过来),当前是B。默认删除标记不复制,所以备份桶没有删除标记。
4. [3] What happens with a default (unversioned) GET on report.csv after Day3 from
project?404 Not Found. A normal GET reads the current version, which is the delete marker. So S3 returns 404. To get the file, you must give Version B's version ID.返回404。普通GET取当前版本=删除标记,所以404;要取文件必须指定Version B的版本ID。
5. [3] How to permanently delete ALL versions of report.csv from both buckets?
A delete without a version ID only adds another delete marker; it does not remove data. To really delete, you must delete every version by its version ID: in
不带版本ID删只会再加一个删除标记,删不掉。要真删必须按版本ID逐个删:project里删A、B和删除标记;project-backup里删A、B。(指定版本的删除不会被复制,所以两个桶都要删;也可用生命周期规则清理旧版本。)
project delete A, B and the delete marker; in project-backup delete A and B. (Version-by-version deletes are not copied, so you must do both buckets. You can also use a lifecycle rule to remove old versions.)Q7 · Amazon Aurora (1 writer + 2 readers) 12 分
Setup: Aurora MySQL, 1 writer + 2 reader replicas, volume in one protection group.
1. [2] How many copies of your data does the storage layer store?
6 copies. Aurora always keeps 6 copies of each segment. This does not depend on how many readers you have.6份。Aurora对每个数据段总是存6份,和有几个读副本无关。
2. [2] Across how many Availability Zones is the data stored?
3 AZs, with 2 copies in each AZ (6 / 3). Using 3 AZs means it can lose one whole AZ and still keep a write quorum.3个AZ,每个AZ放2份(共6份)。跨3个AZ→丢一整个AZ仍能维持写仲裁。
3. [4] When the app writes data, how is the write sent to the nodes?
Only the writer takes writes. It sends just the redo log (not full pages) to the 6 storage nodes. The write is durable once 4 of the 6 confirm (write quorum 4/6). The redo log is also sent to the 2 readers so they update their cache. Readers read from the same shared storage. The storage nodes build the pages from the log later in the background.
只有writer写。它只把redo日志(不是整页)发给6个存储节点;6个里有4个确认(写仲裁4/6)写就算持久。redo日志也发给2个读副本更新缓存;读副本从同一共享存储读。存储节点之后在后台用日志生成数据页。
4. [4] If the volume grows beyond one protection group, what extra resources are needed?
One protection group covers one 10 GB segment, kept as 6 copies across 3 AZs. When the volume grows past 10 GB, Aurora adds more protection groups — more storage nodes/segments, each with its own 6 copies across the 3 AZs. The volume is just a set of protection groups. The compute (writer/readers) does not change; only the storage grows.
一个保护组(PG)管一个10GB段、6副本跨3AZ。卷超过10GB时,Aurora加更多保护组——更多存储节点/段,每个各自6副本跨3AZ。卷就是一堆PG。计算层(writer/读副本)不变,只是存储扩。
Q8 · VPC / Subnet / Security Group 30 分
Setup: VPC 10.0.0.0/16. Public 10.0.1.0/24 (RT-Public 0.0.0.0/0→IGW; ALB+NAT+Bastion). App 10.0.2.0/24 (RT-App 0.0.0.0/0→NAT; web servers). DB 10.0.3.0/24 (Default RT: local only; RDS). SGs: ALB-SG 80←0.0.0.0/0; Bastion-SG 22←0.0.0.0/0; WebServer-SG 80←ALB-SG; RDS-SG 3306←WebServer-SG.
1. [2] Can the RDS connect to the internet?
No. The DB subnet uses the default route table, which has only the local route. There is no route to an IGW or a NAT, so it cannot reach the internet either way.不能。DB子网用默认路由表,只有local路由,没有指向IGW或NAT的路由,双向都上不了网。
2. [4] Describe the full network path when a user accesses the web app. Which route tables and SGs?
User → Internet Gateway → (RT-Public sends it to the public subnet) → ALB (ALB-SG allows port 80 from anywhere) → ALB sends it to a web server in the App subnet over the local route (WebServer-SG allows 80 from ALB-SG) → if needed the web server reads RDS (RDS-SG allows 3306 from WebServer-SG). The reply goes back the same way (SGs are stateful).
Route tables: RT-Public + local route. SGs: ALB-SG → WebServer-SG → RDS-SG.
用户→IGW→(RT-Public送到公有子网)→ALB(放行公网80)→经local路由发到App子网的web(WebServer-SG放行ALB-SG的80)→需要时web读RDS(RDS-SG放行WebServer-SG的3306)→原路返回(SG有状态)。路由表:RT-Public+local;SG:ALB-SG→WebServer-SG→RDS-SG。
Route tables: RT-Public + local route. SGs: ALB-SG → WebServer-SG → RDS-SG.
3. [4] Is the Bastion Host useful here? If not, how to fix it?
Not useful yet. You can reach the bastion (it allows 22 from anywhere and is in the public subnet). But you cannot use it to manage the web/DB servers, because no SG allows SSH from the bastion: WebServer-SG only allows 80 from ALB-SG. Fix: add TCP 22 from Bastion-SG to WebServer-SG (and 3306 from Bastion-SG to RDS-SG if you want to manage the DB).
目前没用。能登堡垒机(对公网开22、在公有子网),但管不了web/DB——没有SG放行来自堡垒机的SSH:WebServer-SG只放ALB-SG的80。修复:给WebServer-SG加"22来自Bastion-SG"(要管库再给RDS-SG加3306来自Bastion-SG)。
4. [4] An EC2 in the DB subnet with a public IP still can't be SSH'd. Two reasons.
Reason 1: the DB subnet has no 0.0.0.0/0 → IGW route, so even with a public IP there is no internet path. Reason 2: no SG rule allows port 22 from the laptop (RDS-SG only allows 3306). Either one alone blocks SSH.
原因1:DB子网没有0.0.0.0/0→IGW的路由,有公网IP也没有上网路径。原因2:没有SG规则放行来自笔记本的22端口(RDS-SG只放3306)。任一条都让SSH失败。
5. [6] A Lambda needs RDS and S3, in a private subnet. Which subnet and what configs?
Put it in the App subnet (it has a route to the NAT; the DB subnet has no internet path and cannot reach S3). Configs:
放App子网(有到NAT的路由;DB子网没网到不了S3)。配置:①函数入VPC、用App子网+自己的Lambda-SG;②连RDS:加"RDS-SG 3306来自Lambda-SG",给数据库登录;③连S3:走NAT,或更好加免费的S3网关端点;④执行角色给S3权限(GetObject/PutObject)。
- Put the function in the VPC with the App subnet and its own Lambda-SG.
- For RDS: add RDS-SG: 3306 from Lambda-SG, and give it the DB login.
- For S3: use the NAT, or better add a free S3 Gateway VPC endpoint.
- Give the execution role S3 permissions (s3:GetObject / s3:PutObject).
6. [4] A temp EC2 to run a MySQL client against RDS — which subnet, how to connect, new SG?
Put the temp EC2 in the App subnet (it can reach RDS over the local route). The subnet is private, so connect through the bastion: SSH to the bastion, then SSH from the bastion to the temp EC2. New SG: make a new SG for the temp EC2 that allows 22 from Bastion-SG, and add that SG to RDS-SG's 3306 rule (or attach WebServer-SG, which RDS already trusts).
放App子网(经local路由可达RDS)。子网是私有的,经堡垒机连:先SSH到堡垒机,再从堡垒机SSH到临时实例。新SG:给临时实例建SG放行"22来自Bastion-SG",并把它加进RDS-SG的3306源(或挂RDS已信任的WebServer-SG)。
7. [6] Classify each IP: routing and external access.
(a) 10.0.2.15 → App subnet. Route to NAT, so it can go out to the internet but cannot be reached from the internet.
(b) 10.0.3.10 → DB subnet. Only the local route, so no internet either way; it only talks inside the VPC.
(c) 10.0.5.55 → inside the VPC range but in NO subnet (subnets are .1/.2/.3). It cannot be given to any resource here; you would need a new subnet.
(a)10.0.2.15=App子网,到NAT,可出网但不可被公网访问。(b)10.0.3.10=DB子网,只有local,双向不通网,仅VPC内通信。(c)10.0.5.55=在VPC范围内但不属于任何子网(只有.1/.2/.3),当前分不给任何资源,需新建子网。
(b) 10.0.3.10 → DB subnet. Only the local route, so no internet either way; it only talks inside the VPC.
(c) 10.0.5.55 → inside the VPC range but in NO subnet (subnets are .1/.2/.3). It cannot be given to any resource here; you would need a new subnet.
Q9 · ALB + ASG 9 分
Setup: ALB on port 80 → target group; health check on port 80; ASG launches from a Launch Template (user-data starts a Python web server on 80); scale out CPU>70%, scale in CPU<30%; min 2, max 5.
1. [2] With 3 instances, how does the ALB distribute traffic?
The ALB uses round-robin by default. It sends requests evenly across the healthy targets — all 3, as long as they pass the port-80 health check. Unhealthy targets get no traffic.ALB默认轮询,只发给通过80健康检查的健康目标,3台均分;不健康的不发。
2. [4] A new launch template has a buggy startup script (web server never starts). What happens to the ASG? What observation tells you to check the script?
New instances start, but the web server never runs on port 80. So they fail the health check and are marked unhealthy. The ASG terminates them and launches new ones from the same bad template. This makes an endless launch–terminate loop. The old healthy instances keep serving.
Observation: in the ASG history, instances are launched and terminated again and again; the target group never gets healthy new targets and capacity never settles. That loop tells you to check the startup script.
新实例起来但web起不到80端口,所以健康检查失败、被标不健康。ASG终止它们、用同一坏模板再开→无限"启动-终止"循环;老的健康实例继续服务。现象:ASG历史里实例反复创建/终止、目标组一直没有健康新目标、容量稳不下来——看到这循环就去查启动脚本。
Observation: in the ASG history, instances are launched and terminated again and again; the target group never gets healthy new targets and capacity never settles. That loop tells you to check the startup script.
3. [3] Two instances: one at 90% CPU, one at 10%. Will the ASG scale out? Why?
No. The ASG looks at the group average CPU: (90 + 10) / 2 = 50%, which is below 70%. So it does not scale out — even though one instance is at 90%.
不会。ASG看组平均CPU:(90+10)/2=50%<70%,所以不扩容——尽管有一台90%。