From ec2f1fdef596e1d46746acf3d404b8bd14cc7984 Mon Sep 17 00:00:00 2001 From: Jongwoo Han Date: Mon, 29 Dec 2025 09:38:33 +0900 Subject: [PATCH 1/4] chore: Add memoryReservation to ECS task definition --- Modules/AWS/ECS/main.tf | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Modules/AWS/ECS/main.tf b/Modules/AWS/ECS/main.tf index 9edc552..230ba81 100644 --- a/Modules/AWS/ECS/main.tf +++ b/Modules/AWS/ECS/main.tf @@ -19,11 +19,12 @@ resource "aws_ecs_task_definition" "ecs_task_definition" { container_definitions = jsonencode([ { - name = "dutymate-container", - image = "${var.ecr_repository_url}:latest", - memory = 768, - cpu = 512, - essential = true, + name = "dutymate-container", + image = "${var.ecr_repository_url}:latest", + cpu = 512, + memoryReservation = 512, + memory = 768, + essential = true, portMappings = [{ containerPort = 8080, hostPort = 8080, From b5cc99da54c054970e56c715090ce9c65d11e22c Mon Sep 17 00:00:00 2001 From: Jongwoo Han Date: Mon, 29 Dec 2025 09:40:17 +0900 Subject: [PATCH 2/4] chore: Enforce one-task-per-instance placement for ECS service --- Modules/AWS/ECS/main.tf | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Modules/AWS/ECS/main.tf b/Modules/AWS/ECS/main.tf index 230ba81..8d4d983 100644 --- a/Modules/AWS/ECS/main.tf +++ b/Modules/AWS/ECS/main.tf @@ -60,6 +60,16 @@ resource "aws_ecs_service" "ecs_service" { deployment_minimum_healthy_percent = 50 deployment_maximum_percent = 100 + capacity_provider_strategy { + capacity_provider = aws_ecs_capacity_provider.capacity_provider.name + base = 2 + weight = 1 + } + + placement_constraints { + type = "distinctInstance" + } + load_balancer { target_group_arn = var.alb_target_group_arn container_port = 8080 From c94ef8f89f6a3221bb817ec6a21427a37fd68164 Mon Sep 17 00:00:00 2001 From: Jongwoo Han Date: Mon, 29 Dec 2025 09:40:35 +0900 Subject: [PATCH 3/4] chore: Tune ECS capacity provider target capacity --- Modules/AWS/ECS/main.tf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Modules/AWS/ECS/main.tf b/Modules/AWS/ECS/main.tf index 8d4d983..239464f 100644 --- a/Modules/AWS/ECS/main.tf +++ b/Modules/AWS/ECS/main.tf @@ -154,10 +154,10 @@ resource "aws_ecs_capacity_provider" "capacity_provider" { managed_termination_protection = "ENABLED" managed_scaling { + status = "ENABLED" + target_capacity = 90 maximum_scaling_step_size = 5 minimum_scaling_step_size = 1 - status = "ENABLED" - target_capacity = 100 } } From eb261595c53278eccea6f5ab295990d495a49bac Mon Sep 17 00:00:00 2001 From: Jongwoo Han Date: Mon, 29 Dec 2025 09:41:37 +0900 Subject: [PATCH 4/4] chore: Set deregistration delay to 30 --- Modules/AWS/ALB/main.tf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Modules/AWS/ALB/main.tf b/Modules/AWS/ALB/main.tf index 9c8ca3e..8cefe0f 100644 --- a/Modules/AWS/ALB/main.tf +++ b/Modules/AWS/ALB/main.tf @@ -18,7 +18,7 @@ resource "aws_alb_target_group" "alb_target_group" { protocol = "HTTP" vpc_id = var.vpc_id target_type = "instance" - deregistration_delay = 5 + deregistration_delay = 30 health_check { path = var.alb_health_check_path