Free — no signup required

Services: The Fleet Manager

2 min read

You rarely run a Task manually. A manually-run Task is a one-shot job — it runs and exits. For long-running workloads (APIs, workers, servers), you define a Service.

"Keep N Running"

A Service has one primary job: maintain a Desired Count of healthy tasks at all times.

  • You declare: "I want 5 tasks running."
  • ECS starts 5 tasks.
  • One crashes at 3 AM. ECS detects the failure within seconds and launches a replacement — no human intervention required.
  • You deploy a new Task Definition revision. The Service performs a rolling update, replacing old tasks with new ones while keeping the total count stable.

Deployment Strategies

ECS Services support two deployment strategies that control how updates are rolled out:

Rolling Update (default):
ECS replaces tasks incrementally. Two parameters control the pace:
- minimumHealthyPercent: The floor. If set to 50%, ECS can terminate half the tasks before replacements are healthy. Lower = faster deploys, higher risk.
- maximumPercent: The ceiling. If set to 200%, ECS can run double the desired count during a deploy (old + new tasks simultaneously). Higher = safer deploys, higher cost.

Blue/Green (via CodeDeploy):
ECS creates an entirely new set of tasks (green), shifts traffic from the ALB to green, and only terminates the old set (blue) after a configurable bake time. This enables instant rollback by shifting traffic back to blue. This is the preferred strategy for zero-downtime deployments of critical services.

Load Balancing Integration

The Service is the component that registers tasks with the Application Load Balancer (ALB). The workflow is automatic:

  1. Service launches a new task. The task gets IP 10.0.1.50 via its ENI.
  2. Service calls the ALB API: "Add 10.0.1.50:8080 to Target Group my-api-tg."
  3. ALB runs health checks against the new task.
  4. Once healthy, the ALB starts routing traffic to it.
  5. When the task stops, the Service triggers connection draining — the ALB stops sending new requests to that task and waits for in-flight requests to complete before deregistering it.

This entire lifecycle is managed by ECS with zero manual steps.

This is one of 18 chapters

Get every chapter — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

See pricing