1 Answer
- Newest
- Most votes
- Most comments
0
In AWS Fargate, the behavior when a workload exceeds the allocated memory limit depends on the configured memory resource limits for the container. Here's what happens in your scenario:
Memory Usage Exceeds Configured Limits (e.g., 6GB):
- Container Memory Limit Configuration:
- When you define a container in AWS Fargate, you specify its memory limits (
memoryormemoryReservationin the task definition).
- When you define a container in AWS Fargate, you specify its memory limits (
memoryReservationis a soft limit, andmemoryis a hard limit- If the workload exceeds the
memorylimit, Fargate enforces these limits, leading to an Out Of Memory (OOM) error.
AWS Fargate 2 vCPU has a memory limit of up to 16GB. See the Fargate pricing details for more information: https://aws.amazon.com/fargate/pricing/
-
Outcome When Limit is Exceeded:
- The container is terminated by Fargate if it consumes more memory than its specified limit.
- If your task is part of a service with auto-restart policies enabled (e.g., ECS Service with
restartPolicy: always), Fargate will attempt to restart the task automatically.
-
Scaling Behavior:
- Fargate does not automatically scale memory or CPU resources beyond the configured task definition limits. You must manually adjust the task definition and redeploy or implement an external scaling mechanism
-
Elasticity in EKS with Fargate:
- Kubernetes itself does not dynamically increase the resource limits of a pod. In your case, if the workload's actual usage exceeded 6GB, the pod would likely be evicted (terminated) due to memory pressure, depending on how the resource requests and limits were configured in the Kubernetes pod spec.
Recommendations:
- Adjust Resource Limits: If your workload can occasionally spike, adjust the
requestsandlimitsin the pod specification (or ECS task definition) to allocate more memory. - Horizontal Pod Autoscaler (HPA): Use Kubernetes HPA to scale the number of pods dynamically based on memory and CPU usage.
- Monitor with CloudWatch: Use CloudWatch or Kubernetes monitoring tools to track resource usage and identify patterns to provision accordingly.
- Graceful Degradation: Implement application-level logic to handle resource constraints gracefully, such as shedding load during high-memory usage scenarios.
answered 2 years ago
Relevant content
asked 2 years ago
asked 2 years ago
asked 2 years ago
- AWS OFFICIALUpdated a year ago
