竞价型实例与高性价比计算
学习如何使用 EC2 竞价型实例和混合实例集群,大幅降低计算成本,同时平稳应对中断。
竞价型实例与高性价比计算 是 CoddyKit 上的免费 AWS for Backend Developers (EC2, S3, RDS, Lambda) 课时。 这是第 4 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 AWS for Backend Developers (EC2, S3, RDS, Lambda) 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 AWS for Backend Developers (EC2, S3, RDS, Lambda) 课程共包含 4 节课。
本课时的部分内容尚未翻译,以英文显示。
What Are Spot Instances?
Spot Instances let you use spare EC2 capacity at discounts of up to 90% versus On-Demand pricing.
The catch: AWS can reclaim them with a short warning when it needs the capacity back.
On-Demand vs Reserved vs Spot
Three pricing models:
- On-Demand — pay per second, no commitment, full price
- Reserved / Savings Plans — commit for 1-3 years, big discount
- Spot — cheapest, but interruptible
Good Workloads for Spot
Spot shines for fault-tolerant, flexible workloads:
- Batch processing and data analysis
- CI/CD build runners
- Stateless web tiers behind a load balancer
- Containerized jobs
The Interruption Notice
Before reclaiming a Spot Instance, AWS sends a two-minute interruption notice via instance metadata. Your app should check for it and shut down gracefully.
curl http://169.254.169.254/latest/meta-data/spot/instance-actionRequesting a Spot Instance
You can request Spot capacity through the CLI, an Auto Scaling group, or a Spot Fleet. Here is a simple run-instances request.
aws ec2 run-instances \
--image-id ami-123 \
--instance-type c6g.large \
--instance-market-options 'MarketType=spot'Spot in Auto Scaling Groups
Auto Scaling groups support a mixed instances policy: combine On-Demand and Spot in one group, so a baseline stays reliable while Spot adds cheap capacity.
Diversification Reduces Risk
Spreading requests across many instance types and Availability Zones lowers the chance all your capacity is interrupted at once. This is called diversification.
Capacity Rebalancing
Capacity Rebalancing proactively launches a replacement instance when a Spot Instance is at elevated risk of interruption, before the two-minute notice fires.
Handling State
Because instances can vanish, keep state off the instance. Store data in S3, RDS, or DynamoDB, and treat compute as disposable.
Spot with Containers
ECS and EKS both support Spot capacity. The orchestrator reschedules tasks/pods when an instance is reclaimed, making Spot especially safe for containerized workloads.
Cost Strategy Summary
A balanced strategy:
- Reserved/Savings Plans for steady baseline load
- On-Demand for unpredictable bursts
- Spot for flexible, fault-tolerant capacity
Quick Check
Test your Spot knowledge.
Recap
You learned cost-efficient compute:
- Spot offers up to 90% savings but is interruptible
- Watch the two-minute interruption notice
- Diversify across types and AZs
- Mix Spot, On-Demand, and Reserved for the best balance
Treat compute as disposable and Spot becomes a powerful cost lever.
用 AI 导师学习 AWS for Backend Developers (EC2, S3, RDS, Lambda) — 免费
在浏览器中编写并运行真实代码,获得全天候 AI 导师的即时帮助,并在网页或应用中继续学习。
- 课程
- 12
- 课程
- 48
常见问题解答
「竞价型实例与高性价比计算」课时是免费的吗?
是的 — 「竞价型实例与高性价比计算」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 AWS for Backend Developers (EC2, S3, RDS, Lambda) 课程的其余内容,请升级到 CoddyKit PRO。 AWS for Backend Developers (EC2, S3, RDS, Lambda) 课程共包含 4 节课。
「竞价型实例与高性价比计算」这节课中我会学到什么?
学习如何使用 EC2 竞价型实例和混合实例集群,大幅降低计算成本,同时平稳应对中断。 你通过在浏览器中直接运行的动手代码来练习 AWS for Backend Developers (EC2, S3, RDS, Lambda),全天候 AI 导师会在你学习这节课的过程中回答你的问题。
学习 AWS for Backend Developers (EC2, S3, RDS, Lambda) 需要有经验吗?
无需任何先前经验。CoddyKit 上的 AWS for Backend Developers (EC2, S3, RDS, Lambda) 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 4 节课,共 4 节。
「竞价型实例与高性价比计算」课时需要多长时间?
大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。
我能在这节 AWS for Backend Developers (EC2, S3, RDS, Lambda) 课中编写并运行代码吗?
能。每节 AWS for Backend Developers (EC2, S3, RDS, Lambda) 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。
此课程中的所有课时
- EC2 实例类型与 AMI
- 实施自动扩缩组
- 使用 ELB 进行负载均衡
- 竞价型实例与高性价比计算