fix: add task-level CPU and memory limits#773
Open
igor-soldev wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
This PR introduces explicit, task-level CPU and memory limits to our ECS task definitions.
This addresses the
ECS Task Definition Without CPU/Memory Limitsissue discovered by InfraScan during the setup in #772.Previously, we were assigning
memory = var.container_memory_hard_limitdirectly on the task level, and we omitted thecpulimit entirely. While this worked for single-container tasks, it lacked flexibility (e.g., if we ever wanted to add a sidecar container, the task memory needs to be the sum of all containers). Furthermore, omitting the task-levelcpumakes it difficult for the ECS scheduler to place tasks efficiently and can lead to resource overprovisioning.To fix this and make the module more robust, two new variables were introduced:
task_cputask_memoryDefault values (Action Required)
To ensure backward compatibility and prevent production outages during deployment, safe default values have been applied:
task_cpu= 1024 (1 vCPU) – Prevents unbounded CPU bursts, but will throttle the task if the app suddenly demands more power.task_memory= Falls back tocontainer_memory_hard_limit– Ensures we don't accidentally cut memory off from existing setups (currently resulting in 3072 MiB for the API).Request for metrics review
Before merging, we should verify our actual resource usage in CloudWatch Container Insights to avoid deployment blockages or production starvation:
1024CPU units sufficient for our historical traffic spikes? If it regularly exceeds this, we need to manually overridetask_cpuwhen calling the module (e.g., to2048).Let's discuss the metrics and adjust the defaults if necessary before merging.