Amazon ECS: Running Containers on AWS
By the end of this lesson, you'll be able to:
- Explain the ECS cluster, service, task, and task definition relationship
- Distinguish a task definition (a blueprint) from a task (a running instance) and a service (which maintains a desired count)
- Describe how a load-balanced ECS service distributes traffic across healthy tasks in multiple Availability Zones
Prerequisites: "Amazon ECR: Storing Container Images"
ECS: orchestrating where and how containers run
Amazon ECS (Elastic Container Service) is AWS's container orchestration service — it decides where containers run, keeps the right number of them running, and replaces ones that stop working. An ECS cluster is the logical grouping ECS workloads run within; this lesson doesn't require memorizing every cluster configuration detail, since specifics vary by launch type (the next lesson covers one launch type, Fargate, in depth).
Task definition, task, and service — the distinction that matters most
Three terms are easy to blur together, and doing so causes real confusion later:
- A task definition is a blueprint — a configuration document describing which container image to run, how much CPU and memory to give it, and other settings. It is not something running by itself.
- A task is one running instantiation of a task definition — an actual running container (or set of containers), created according to that blueprint.
- A service maintains a desired number of tasks running at once, for long-running workloads — if a task stops unexpectedly, the service works to replace it and keep the desired count running.
A load-balanced service: building on Module 6
A common, realistic pattern places an ECS service's tasks behind an Application Load Balancer, with tasks spread across multiple Availability Zones — exactly the multi-AZ load-balancing pattern Module 6 introduced for EC2 targets, applied here to container tasks instead.
Health checks are how the load balancer (and the ECS service) know whether a task is actually working — an unhealthy task stops receiving new traffic, and depending on configuration, the service may replace it. This lesson deliberately avoids overstating what a health check proves: a check that only confirms an HTTP response from / doesn't necessarily prove every part of the application is genuinely healthy — a meaningful health check should reflect something closer to real application readiness where practical.
Exercise
For each of the following, decide whether it describes a task definition, a task, or a service: (1) "maintain 3 running copies of the web application container at all times," (2) "a configuration document specifying the container image, CPU, and memory to use," (3) "one actual running container created according to that configuration." Then explain, in your own words, why a task definition alone doesn't keep anything running.
Show hint
Match each description to the term that matches its role: blueprint, running instance, or desired-count maintainer.
Amazon ECS: Running Containers on AWS Quiz
My Notes
Log in to keep private notes on this lesson.
Questions about this lesson
No questions yet — be the first to ask.
Log in to ask a question about this lesson.
Summary
Amazon ECS is a container orchestration service: a task definition is the blueprint describing a container and its configuration, a task is one running instantiation of that blueprint, and a service maintains a desired number of running tasks, commonly behind a load balancer that distributes traffic across tasks running in multiple Availability Zones.