Jonatan Matajonmatum.com
conceptsnotesexperimentsessays
© 2026 Jonatan Mata. All rights reserved.v2.1.1
Concepts

AWS ECS

AWS container orchestration service that runs and scales Docker applications without managing the underlying cluster infrastructure.

evergreen#aws#ecs#containers#docker#orchestration#cloud

What it is

Amazon ECS (Elastic Container Service) is AWS's native container orchestration service. It runs Docker containers at scale with two launch modes: EC2 (you manage instances) and Fargate (serverless, AWS manages infrastructure).

ECS abstracts container orchestration complexity while maintaining deep integration with the AWS ecosystem. Unlike Kubernetes, ECS is designed specifically for AWS, resulting in less configuration and better integration with services like IAM, CloudWatch, and Application Load Balancer.

Its architecture is based on four fundamental concepts: task definitions (blueprints), tasks (running instances), services (desired state maintenance), and clusters (logical grouping). This conceptual simplicity allows teams to focus on their applications rather than orchestrator operational complexity.

Key concepts and architecture

ConceptFunctionK8s equivalent
Task DefinitionContainer blueprint (image, CPU, memory, ports)Pod spec
TaskRunning instance of a task definitionPod
ServiceMaintains N running tasks with load balancingDeployment + Service
ClusterLogical grouping of tasks and servicesCluster + Namespace

Task Definition example

{
  "family": "web-app",
  "networkMode": "awsvpc",
  "requiresCompatibilities": ["FARGATE"],
  "cpu": "256",
  "memory": "512",
  "executionRoleArn": "arn:aws:iam::123456789012:role/ecsTaskExecutionRole",
  "taskRoleArn": "arn:aws:iam::123456789012:role/ecsTaskRole",
  "containerDefinitions": [
    {
      "name": "web-server",
      "image": "nginx:latest",
      "portMappings": [
        {
          "containerPort": 80,
          "protocol": "tcp"
        }
      ],
      "essential": true,
      "logConfiguration": {
        "logDriver": "awslogs",
        "options": {
          "awslogs-group": "/ecs/web-app",
          "awslogs-region": "us-east-1",
          "awslogs-stream-prefix": "ecs"
        }
      },
      "environment": [
        {
          "name": "ENV",
          "value": "production"
        }
      ],
      "secrets": [
        {
          "name": "DB_PASSWORD",
          "valueFrom": "arn:aws:secretsmanager:us-east-1:123456789012:secret:db-password"
        }
      ]
    }
  ]
}

Capacity Providers and cost strategies

Capacity Providers determine where and how tasks run, with different cost and control tradeoffs:

Fargate

  • Cost: $0.04048/vCPU/hour + $0.004445/GB/hour
  • Advantages: No infrastructure management, instant scaling
  • Ideal for: Microservices, variable workloads, small teams

Fargate Spot

  • Cost: Up to 70% discount over regular Fargate
  • Advantages: Same serverless model with significant discount
  • Limitations: Can be interrupted with 2-minute notice
  • Ideal for: Batch processing, interruption-tolerant workloads

EC2

  • Cost: EC2 instance price + minimal ECS overhead
  • Advantages: Full control, cost optimization for predictable workloads
  • Disadvantages: Instance management, patching, manual scaling
  • Ideal for: Stable workloads, teams with infrastructure experience

Mixed configuration example

{
  "capacityProviders": ["FARGATE", "FARGATE_SPOT", "EC2"],
  "defaultCapacityProviderStrategy": [
    {
      "capacityProvider": "FARGATE",
      "weight": 1,
      "base": 2
    },
    {
      "capacityProvider": "FARGATE_SPOT",
      "weight": 4
    }
  ]
}

Deployment strategies

Rolling Update (default)

  • Gradually replaces tasks while maintaining availability
  • Configurable: minimumHealthyPercent and maximumPercent
  • Ideal for most web applications

Blue-Green with CodeDeploy

  • Complete deployment to new version with instant rollback
  • Requires two target groups in ALB
  • Ideal for critical applications requiring fast rollback
# CodeDeploy configuration
DeploymentConfiguration:
  BlueGreenDeploymentConfiguration:
    TerminateBlueInstancesOnDeploymentSuccess:
      Action: TERMINATE
      TerminationWaitTimeInMinutes: 5
    DeploymentReadyOption:
      ActionOnTimeout: CONTINUE_DEPLOYMENT
    GreenFleetProvisioningOption:
      Action: COPY_AUTO_SCALING_GROUP

Circuit Breaker

  • Automatically stops deployments if health checks fail
  • Prevents failure cascades in problematic deployments
  • Configurable per service
{
  "deploymentConfiguration": {
    "deploymentCircuitBreaker": {
      "enable": true,
      "rollback": true
    },
    "maximumPercent": 200,
    "minimumHealthyPercent": 50
  }
}

Service Discovery and networking

AWS Cloud Map

  • Native DNS-based service discovery
  • Automatic Route 53 integration
  • Health check support

Service Connect

  • Simplified service mesh for ECS
  • Transparent proxy with integrated observability
  • Ideal for service-to-service communication

Internal Application Load Balancer

  • HTTP/HTTPS load balancing between services
  • Target group integration
  • Path-based and host-based routing
{
  "serviceRegistries": [
    {
      "registryArn": "arn:aws:servicediscovery:us-east-1:123456789012:service/srv-xyz",
      "containerName": "web-server",
      "containerPort": 80
    }
  ]
}

ECS vs EKS: comparative analysis

DimensionECSEKS
Operational complexityLow — AWS manages control planeHigh — requires K8s expertise
Ideal team size2-10 engineers10+ engineers with K8s dedication
Monthly cost (10 services)~$200 (compute only)~$270 ($72 control plane + compute)
Time to production1-2 weeks4-8 weeks
PortabilityAWS lock-inMulti-cloud, on-premises
EcosystemNative AWS toolsHelm, operators, CNCF ecosystem
Learning curveModerateSteep

Debugging and observability

ECS Exec

Allows executing commands inside running containers, similar to kubectl exec:

# Enable ECS Exec in task definition
aws ecs execute-command \
  --cluster my-cluster \
  --task arn:aws:ecs:us-east-1:123456789012:task/abc123 \
  --container web-server \
  --interactive \
  --command "/bin/bash"

Container Insights

  • Automatic CPU, memory, network, disk metrics
  • Pre-configured CloudWatch dashboards
  • Customizable threshold-based alerts

Key metrics for monitoring

# Recommended CloudWatch Alarms
CPUUtilization: >80% for 5 minutes
MemoryUtilization: >85% for 5 minutes
TaskCount: <desired_count for 2 minutes
TargetResponseTime: >500ms for 3 minutes

Architecture patterns

Microservices with ALB

  • Each service exposed via ALB with path-based routing
  • Service discovery via Cloud Map
  • Shared VPC with private subnets

Batch Processing

  • Tasks that run and terminate
  • EventBridge integration for scheduling
  • Fargate Spot for cost optimization

Sidecar Pattern

  • Auxiliary containers (logging, monitoring, proxy)
  • Shared volumes between containers
  • Coordinated lifecycle management

Why it matters

ECS represents the sweet spot between simplicity and capability for most teams running containers on AWS. While Kubernetes offers more flexibility and portability, ECS significantly reduces operational complexity — no control plane to manage, updates to plan, or certificates to rotate. For teams that don't need Kubernetes' multi-cloud portability, ECS enables faster value delivery with less operational overhead. Native integration with IAM, CloudWatch, and other AWS services eliminates the typical friction of setting up observability and security that exists in Kubernetes ecosystems.

References

  • Amazon ECS Developer Guide — AWS, 2024. Complete official documentation.
  • ECS Best Practices Guide — AWS, 2024. Best practices for containers on ECS.
  • ECS Deployment Types — AWS, 2024. Deployment strategies guide.
  • ECS Pricing — AWS, 2024. Pricing model and calculator.
  • Container Insights for ECS — AWS, 2024. Monitoring and observability.
  • ECS vs EKS Decision Guide — AWS, 2023. Detailed comparison for decision making.

Related content

  • Docker

    Container platform that packages applications with all dependencies into portable, consistent units that run identically in any environment.

  • AWS Fargate

    Serverless compute engine for containers that eliminates server management, allowing Docker container execution paying only for consumed resources.

  • Microservices

    Architectural style structuring an application as a collection of small, independent, deployable services, each with its own business logic and data.

  • Terraform AWS Serverless Modules

    Collection of 13 Terraform modules published on the Terraform Registry for deploying serverless architectures on AWS, with 12 examples covering basic ECS to full-stack CRUD with DynamoDB and AgentCore with MCP.

Concepts