使用CodePipeline部署ECS可能会因CPU单位不足而失败并超时。

huangapple go评论78阅读模式
英文:

Deploying Ecs with CodePipelin may fail and time out due to lack of CPU units

问题

以下是您要翻译的内容:

我的配置是从CircleCI上传图像到ECR,捕获Codepipeline中的更改并部署到ECS。

在部署到ECS时发生错误。

服务dev-test无法放置任务,因为没有容器实例满足其所有要求。最接近的匹配容器实例xxxxxxx没有足够的CPU单位可用。有关更多信息,请参阅Amazon ECS开发者指南的故障排除部分。

我可以预期由于CPU不足而无法执行任务,但是从CircleCI到ECS部署或手动部署时不会发生此错误。
这个问题的解决方案是什么?

此外,我不知道是否与此问题相关,但我将AutoScaling设置为最小2和最大4,但即使CPU不足,AutoScaling也不运行,我收到错误消息。
这个问题是否也与此问题相关?

容器实例

CPU:.5 vCPU
内存:3GB

CPU剩余空间:512
空闲内存:769

task_definition.json

{
    "family": "development",
    "containerDefinitions": [
        {
            "name": "nginx",
            "cpu": 512,
            "memoryReservation": 1024
        },
        {
            "name": "app",
            "cpu": 512,
            "memoryReservation": 1024
        },
        {
            "name": "aws-otel-collector",
            "cpu": 512,
            "memoryReservation": 1024
        }
    ],
    "requiresCompatibilities": [
        "EC2"
    ],
    "cpu": "1536",
    "memory": "3072",
    "runtimePlatform": {
        "cpuArchitecture": "X86_64",
        "operatingSystemFamily": "LINUX"
    }
}

我已配置集群的容量提供程序以解决此问题。

所需大小:2
最小大小:2
最大大小:4

服务的自动缩放也已设置。

最小2
最大4

结果,两个容器实例会永久启动。

在这种情况下,我假设如果在部署时CPU不足,将启动新的容器实例。

然而,在现实中,出现了我之前提到的错误,并且没有显示发生了扩展。

因此,出现了几个问题。

  • 容量提供程序和自动缩放在部署期间不起作用吗?
  • 增加每个容器实例的CPU容量是否会解决此问题?
  • 是否可以仅在部署期间暂时增加CPU容量?

如果有人可以帮助我理解这个问题,请回答。

英文:

My configuration is to upload an Image from CircleCI to ECR, catch the changes in Codepipeline and deploy to ECS.

At that time, an error occurs when deploying to ECS.

service dev-test was unable to place a task because no container instance met all of its requirements. The closest matching container-instance xxxxxxxx has insufficient CPU units available. For more information, see the Troubleshooting section of the Amazon ECS Developer Guide.

I can expect that the task cannot be executed due to lack of CPU, but this error does not occur when deploying from CircleCI to ECS or deploying manually.
What is the solution to this problem?

Also, I don't know if this is related to this issue, but I have AutoScaling set to 2 for minimum and 4 for maximum, but AutoScaling is not running even though there is not enough CPU, and I get an error.
Is this problem also related to this issue?

Container instance

CPU: .5 vCPU
Memory: 3GB

CPU free space: 512
Free Memory: 769

task_definition.json

{
    "family": "development",
    "containerDefinitions": [
        {
            "name": "nginx",
            "cpu": 512,
            "memoryReservation": 1024
        },
        {
            "name": "app",
            "cpu": 512,
            "memoryReservation": 1024
        },
        {
            "name": "aws-otel-collector",
            "cpu": 512,
            "memoryReservation": 1024
        }
    ],
    "requiresCompatibilities": [
        "EC2"
    ],
    "cpu": "1536",
    "memory": "3072",
    "runtimePlatform": {
        "cpuArchitecture": "X86_64",
        "operatingSystemFamily": "LINUX"
    }
}

I have configured the cluster's capacity provider to resolve this issue.

Required size: 2
Minimum size: 2
Maximum size: 4

AutoScaling for the service is also set.

Minimum 2
Maximum 4

This results in two container instances being launched permanently.

With this setup, I had assumed that if there was not enough CPU at deployment time, a new container instance would be launched.

However, in reality, the error I mentioned earlier was displayed and there was no indication that a scale-out had taken place.

So several questions arose.

  • Would capacity providers and AutoScaling not work during deployment?
  • Would increasing the CPU capacity of each container instance solve this problem?
  • Is it possible to temporarily increase CPU capacity only during deployment?

If anyone can help me understand this issue, please answer.

答案1

得分: 1

你的 ECS 任务 太大了,无法适应 EC2 实例。尝试创建一个具有更多 CPU 和内存的任务的新版本。

英文:

Your ECS Task is too big and cannot fit on the EC2 instance. Try creating a new revision of the task with more CPU and memory

答案2

得分: 0

Sounds like you have configured ECS Service autoscaling. The error is that you don't have an EC2 instance registered with the cluster that has available space to run the task. You need to configure a cluster capacity provider with an EC2 auto-scaling group in order for ECS to automatically add EC2 instances to the cluster when they are needed.

英文:

> I have AutoScaling set to 2 for minimum and 4 for maximum

This sounds like you have configured ECS Service autoscaling. The error is that you don't have an EC2 instance registered with the cluster that has available space to run the task. You need to configure a cluster capacity provider with an EC2 auto-scaling group in order for ECS to automatically add EC2 instances to the cluster when they are needed.

huangapple
  • 本文由 发表于 2023年7月10日 13:51:56
  • 转载请务必保留本文链接:https://go.coder-hub.com/76650951.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定