2.1 KiB
2.1 KiB
title, type, tags, sources, last_updated
| title | type | tags | sources | last_updated | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Canary Deployment | concept |
|
|
2026-05-05 |
Canary Deployment
Definition
金丝雀部署(Canary Deployment)是一种软件发布策略,通过将新版本逐步推向一小部分用户来降低风险——在新版本全面推广前,先将少量流量导向新版本,观察其行为和性能,验证无误后再逐步扩大比例。
Core Mechanism
- 流量分割:将用户流量按比例分割(如 5%/10%/50%/100%)
- 逐步提升:从低比例开始,逐步增加新版本流量
- 快速回滚:发现问题时,立即将流量切回旧版本
Implementation in AWS
ECS (Elastic Container Service)
ECS 模块支持金丝雀部署,通过 Target Group 权重调整实现流量控制:
- 创建新旧两个 Task Definition
- 通过 ALB/NLB 的 Target Group 逐步调整权重
- 结合 CloudWatch 监控自动决策扩缩比例
EKS (Elastic Kubernetes Service)
Kubernetes 原生支持金丝雀部署,通过以下机制:
ReplicaSet控制新旧版本副本数Service选择器配合金丝雀标签- Argo Rollouts 等高级工具提供声明式金丝雀策略
AWS Tools
- AWS CodeDeploy:原生支持 ECS 和 Lambda 的金丝雀部署策略
- ALB Target Groups:权重路由实现流量分割
- CloudWatch:金丝雀指标监控
Comparison with Other Deployment Strategies
| 策略 | 风险 | 成本 | 适用场景 |
|---|---|---|---|
| Blue-Green | 中 | 高(双倍资源) | 快速回滚需求 |
| Canary | 低 | 中 | 生产验证 |
| Rolling | 中 | 低 | 资源受限环境 |
| A/B Testing | 低 | 中 | 功能验证 |
Key Metrics to Monitor
- 错误率(5xx)
- 延迟(P50/P95/P99)
- 业务指标(转化率/点击率)
- 资源利用率
Related Concepts
- Blue-Green-Deployment:双环境切换策略
- ECS-Module-Deployment:ECS 场景的模块化部署
- Infrastructure-as-Code:部署自动化基础