aws
resource_error
ai_generated
true
服务无法放置任务:原因:CPU资源不足
service unable to place tasks: reason: resource CPU was insufficient
ID: aws/ecs-task-stopped-resource-cpu
80%修复率
85%置信度
1证据数
2023-04-12首次发现
版本兼容性
| 版本 | 状态 | 引入 | 弃用 | 备注 |
|---|---|---|---|---|
| ECS 1.62.0 | active | — | — | — |
| AWS CLI 2.15.0 | active | — | — | — |
根因分析
ECS集群或容量提供者没有足够的可用CPU单元来运行任务定义中预留的CPU资源。
English
ECS cluster or capacity provider does not have enough available CPU units to run the task definition's CPU reservation.
官方文档
https://docs.aws.amazon.com/AmazonECS/latest/developerguide/service-event-messages.html解决方案
-
通过增加更多EC2实例或扩展Auto Scaling组来扩展ECS集群: aws autoscaling update-auto-scaling-group --auto-scaling-group-name my-asg --desired-capacity 10 --min-size 5 --max-size 20
-
使用Fargate启动类型或Fargate容量提供者并启用自动扩展: aws ecs create-service --cluster my-cluster --service-name my-service --task-definition my-task --launch-type FARGATE --network-configuration ...
-
在任务定义中减少CPU预留以适应集群可用资源: { "family": "my-task", "containerDefinitions": [{ "name": "my-container", "cpu": 256, "memory": 512 }] }
无效尝试
常见但无效的做法:
-
Increase task CPU reservation in task definition
95% 失败
Increasing CPU reservation makes the problem worse, as it requires even more CPU from the cluster.
-
Set service desired count to 0 and back to original
90% 失败
Recycling the service does not create new capacity; the underlying resource shortage remains.
-
Add more memory without adding CPU capacity
85% 失败
Memory is separate from CPU; the error is explicitly about CPU, so memory adjustments don't help.