2

I have an ECS Service that uses multiple tasks in order to execute a daily job. The memory that every task uses varies depending on the data it process. I have set to 16GB Ram in all my tasks but some tasks stopped with the following error "OutOfMemory".

Unfortunately, I can't break down the data that each task process because it has to be processed all together in order to produce the insights I want.

I know how to set up alarms for ECS Services for RAM and CPU. But RAM and CPU for the service refer to the Average of CPU and RAM for all tasks.

How can I set an alarm in order to trigger when a Task runs out of memory? Is there a suggested way to not encounter the OutOfMemory error ?

dapo
  • 697
  • 1
  • 12
  • 22

1 Answers1

1

I believe you have to enable ECS CloudWatch Container Insights to get per-task and per-container memory usage. Once you do that you will begin to see metrics for task memory usage (among other things) in CloudWatch that you can create alarms for.

Note that there is an added cost involved with enabling Container Insights.


Is there a suggested way to not encounter the OutOfMemory error ?

From an infrastructure perspective, all you can do is start provisioning more RAM for your tasks.

From an application perspective you could analyze your application for memory leaks, and examine the data structures your application is creating in memory for possible opportunities, like reducing duplicated data in memory, or moving some of the data to disk, or to a distributed cache. This sort of memory optimization work is extremely application specific.

Mark B
  • 183,023
  • 24
  • 297
  • 295