Interview Prep/AWS/ECS, EKS, ECR and Lambda

A task stops with `Essential container in task exited`, exit code 137, and reason `OutOfMemoryError: Container killed due to memory usage`.

BeginnerTroubleshootingECS, EKS, ECR and Lambda
Answer

Likely causes → The container went over its hard memory limit, so the kernel OOM killer sent SIGKILL (137 = 128 + 9). A JVM heap that is not sized to the container limit, or a memory leak, are the usual reasons.

Diagnose →

aws ecs describe-tasks --cluster prod --tasks <task-arn> \
  --query 'tasks[].containers[].[name,exitCode,reason]'
# Container Insights: MemoryUtilized vs MemoryReserved per task
aws logs tail /ecs/api --since 30m

Fix →

  1. Raise the task or container memory
  2. Size runtimes to the container: -XX:MaxRAMPercentage=75 for Java, --max-old-space-size for Node.js
  3. Fix the leak (take a heap dump before you hit the limit)

Prevent → Turn on Container Insights, alarm on memory utilization above 85%, and load-test with production-like data.

aws All AWS questions Roadmap: EKS, ECS & serverless on AWS

More on ECS, EKS, ECR and Lambda