Skip to content

Memory soft limit in task definition

0

Hi every one

I have only one service with Memory soft limit is 0.5 and CPU is 0 running in ec2 m5.large. I see my ram using 700% can it make my service down ? In my ecs event I see service abc has started 1 tasks: task c7ae6asadsadsd. Amazon ECS replaced 1 tasks due to an unhealthy status.

Thanks for reading

asked 2 years ago714 views

1 Answer
0

The situation you're describing could indeed lead to service instability and potential downtime. Let's break down the key points:

  1. 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.

  2. Actual Memory Usage: You're observing 700% RAM usage, which significantly exceeds the soft limit you've set.

  3. CPU Limit: You've set the CPU limit to 0, which means the task can use as much CPU as available on the instance.

  4. 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:

  1. Increase the memory soft limit to a more appropriate value based on your application's actual needs.
  2. Consider setting a memory hard limit to prevent excessive memory usage.
  3. Monitor your application to understand why it's using so much more memory than allocated and optimize if possible.
  4. 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

answered 2 years ago

EXPERT

reviewed 2 years ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.