admin管理员组

文章数量:1026989

Background: I'm trying to cut the cost of my instance down in half. A t3.medium (2 vCPU, 4 GiB) costs about $.04/hour while a t3.small (2 vCPU, 2 GiB) costs about $.02/hour.

As stated in the title, my Task Definition is made up of an app, database, and api. Theoretically, my memory and compute configurations for each container do "fit" within the t3.small instance (2 vCPU, 2 GiB). While true, after provisioning a t3.small and when creating a service in my cluster, the tasks don't run. However, when I create a new t3.medium instance and retry creating the service, everything runs smoothly.

From what I understand, the t3.small instance isn't quite large enough because there still needs to be some memory for things like the ECS agent (among other things). Therefore, I've gradually been decreasing the amount of CPU and Memory for each container so that I can make room for these things. At the same time, I get the following exception, which tells me that I've decreased the memory capacity too far for one of the containers:

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

Question(s): How should I configure my container resources to get to the point where my service runs? Are there any tools that I can use to see how much compute or memory I'm missing/need?

My Task Definition:

{
    "family": "blazor_app_task",
    "containerDefinitions": [
        {
            "name": "blazor_app_container",
            "image": "thecodeiackiller/exercise-api-app",
            "cpu": 205,
            "memory": 128,
            "memoryReservation": 102,
            "portMappings": [
                {
                    "name": "blazor_app_container-8080-tcp",
                    "containerPort": 8080,
                    "hostPort": 8080,
                    "protocol": "tcp"
                }
            ],
            "essential": true,
            
            "mountPoints": [],
            "volumesFrom": [],
            "logConfiguration": {
                "logDriver": "awslogs",
                "options": {
                    "awslogs-group": "/ecs/blazor_app_task",
                    "mode": "non-blocking",
                    "awslogs-create-group": "true",
                    "max-buffer-size": "25m",
                    "awslogs-region": "us-east-1",
                    "awslogs-stream-prefix": "ecs"
                },
                "secretOptions": []
            },
            "systemControls": []
        },
        {
            "name": "sqlserver",
            "image": "mcr.microsoft/mssql/server:2022-latest",
            "cpu": 1024,
            "memory": 922,
            "memoryReservation": 819,
            "portMappings": [
                {
                    "name": "sqlserver-1433-tcp",
                    "containerPort": 1433,
                    "hostPort": 1433,
                    "protocol": "tcp"
                }
            ],
            "essential": true,
           
            "mountPoints": [],
            "volumesFrom": [],
            "healthCheck": {
                "command": [
                    "CMD-SHELL",
                    "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P 'strongpassword' -Q \"SELECT 1\" || exit 1"
                ],
                "interval": 30,
                "timeout": 5,
                "retries": 3,
                "startPeriod": 45
            },
            "systemControls": []
        },
        {
            "name": "exercise-api",
            "image": "thecodeiackiller/exercise-api-api",
            "cpu": 307,
            "memory": 128,
            "memoryReservation": 102,
            "portMappings": [
                {
                    "name": "exercise-api-8080-tcp",
                    "containerPort": 5000,
                    "hostPort": 5000,
                    "protocol": "tcp"
                }
            ],
            "essential": true,
            "mountPoints": [],
            "volumesFrom": [],
            "systemControls": []
        }
    ],
    "taskRoleArn": "arn:aws:iam::448049819404:role/ecsTaskExecutionRole",
    "executionRoleArn": "arn:aws:iam::448049819404:role/ecsTaskExecutionRole",
    "networkMode": "awsvpc",
    "volumes": [],
    "placementConstraints": [],
    "requiresCompatibilities": [
        "EC2"
    ],
    "cpu": "2048",
    "memory": "2048",
    "runtimePlatform": {
        "cpuArchitecture": "X86_64",
        "operatingSystemFamily": "LINUX"
    },
    "enableFaultInjection": false
}

Background: I'm trying to cut the cost of my instance down in half. A t3.medium (2 vCPU, 4 GiB) costs about $.04/hour while a t3.small (2 vCPU, 2 GiB) costs about $.02/hour.

As stated in the title, my Task Definition is made up of an app, database, and api. Theoretically, my memory and compute configurations for each container do "fit" within the t3.small instance (2 vCPU, 2 GiB). While true, after provisioning a t3.small and when creating a service in my cluster, the tasks don't run. However, when I create a new t3.medium instance and retry creating the service, everything runs smoothly.

From what I understand, the t3.small instance isn't quite large enough because there still needs to be some memory for things like the ECS agent (among other things). Therefore, I've gradually been decreasing the amount of CPU and Memory for each container so that I can make room for these things. At the same time, I get the following exception, which tells me that I've decreased the memory capacity too far for one of the containers:

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

Question(s): How should I configure my container resources to get to the point where my service runs? Are there any tools that I can use to see how much compute or memory I'm missing/need?

My Task Definition:

{
    "family": "blazor_app_task",
    "containerDefinitions": [
        {
            "name": "blazor_app_container",
            "image": "thecodeiackiller/exercise-api-app",
            "cpu": 205,
            "memory": 128,
            "memoryReservation": 102,
            "portMappings": [
                {
                    "name": "blazor_app_container-8080-tcp",
                    "containerPort": 8080,
                    "hostPort": 8080,
                    "protocol": "tcp"
                }
            ],
            "essential": true,
            
            "mountPoints": [],
            "volumesFrom": [],
            "logConfiguration": {
                "logDriver": "awslogs",
                "options": {
                    "awslogs-group": "/ecs/blazor_app_task",
                    "mode": "non-blocking",
                    "awslogs-create-group": "true",
                    "max-buffer-size": "25m",
                    "awslogs-region": "us-east-1",
                    "awslogs-stream-prefix": "ecs"
                },
                "secretOptions": []
            },
            "systemControls": []
        },
        {
            "name": "sqlserver",
            "image": "mcr.microsoft/mssql/server:2022-latest",
            "cpu": 1024,
            "memory": 922,
            "memoryReservation": 819,
            "portMappings": [
                {
                    "name": "sqlserver-1433-tcp",
                    "containerPort": 1433,
                    "hostPort": 1433,
                    "protocol": "tcp"
                }
            ],
            "essential": true,
           
            "mountPoints": [],
            "volumesFrom": [],
            "healthCheck": {
                "command": [
                    "CMD-SHELL",
                    "/opt/mssql-tools18/bin/sqlcmd -C -S localhost -U sa -P 'strongpassword' -Q \"SELECT 1\" || exit 1"
                ],
                "interval": 30,
                "timeout": 5,
                "retries": 3,
                "startPeriod": 45
            },
            "systemControls": []
        },
        {
            "name": "exercise-api",
            "image": "thecodeiackiller/exercise-api-api",
            "cpu": 307,
            "memory": 128,
            "memoryReservation": 102,
            "portMappings": [
                {
                    "name": "exercise-api-8080-tcp",
                    "containerPort": 5000,
                    "hostPort": 5000,
                    "protocol": "tcp"
                }
            ],
            "essential": true,
            "mountPoints": [],
            "volumesFrom": [],
            "systemControls": []
        }
    ],
    "taskRoleArn": "arn:aws:iam::448049819404:role/ecsTaskExecutionRole",
    "executionRoleArn": "arn:aws:iam::448049819404:role/ecsTaskExecutionRole",
    "networkMode": "awsvpc",
    "volumes": [],
    "placementConstraints": [],
    "requiresCompatibilities": [
        "EC2"
    ],
    "cpu": "2048",
    "memory": "2048",
    "runtimePlatform": {
        "cpuArchitecture": "X86_64",
        "operatingSystemFamily": "LINUX"
    },
    "enableFaultInjection": false
}

本文标签: