- Newest
- Most votes
- Most comments
The situation you're describing could indeed lead to service instability and potential downtime. Let's break down the key points:
-
Memory Soft Limit: You've set a memory soft limit of 0.5 GB (512 MB) for your task. This is a relatively low amount of memory for most applications.
-
Actual Memory Usage: You're observing 700% RAM usage, which significantly exceeds the soft limit you've set.
-
CPU Limit: You've set the CPU limit to 0, which means the task can use as much CPU as available on the instance.
-
Instance Type: You're using an m5.large instance, which has 8 GB of memory.
The memory soft limit in ECS is more of a guideline than a hard constraint. When a container exceeds its soft limit, ECS doesn't immediately terminate it. However, if the host instance starts running out of memory, ECS will start killing containers that have exceeded their soft limits to free up resources.
The event you're seeing ("Amazon ECS replaced 1 tasks due to an unhealthy status") suggests that your task is indeed being terminated and replaced due to resource issues, likely related to the high memory usage.
To address this issue:
- Increase the memory soft limit to a more appropriate value based on your application's actual needs.
- Consider setting a memory hard limit to prevent excessive memory usage.
- Monitor your application to understand why it's using so much more memory than allocated and optimize if possible.
- If your application genuinely needs more resources, consider using a larger instance type or switching to Fargate, which allows more flexible resource allocation.
Remember, setting appropriate resource limits is crucial for maintaining stable and efficient ECS tasks. It's important to balance between allocating enough resources for your application to run smoothly and avoiding over-provisioning, which can lead to wasted resources.
Sources
Troubleshoot Amazon ECS task definition invalid CPU or memory errors - Amazon Elastic Container Service
Amazon ECS task definition parameters - Amazon Elastic Container Service
Does ECS have a limitation where only one task can run on the same EC2 instance? | AWS re:Post
Relevant content
asked 2 years ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated a year ago
