Easy ReviewSAA-C03
Design Resilient Architectures22

ECS

Run container tasks with service scheduling, IAM roles, deployment recovery, and automatic scaling.

ECS runs tasks from container definitions. These sections explain how services maintain tasks, deploy changes, scale capacity, and expose failure details.

Task definitions, tasks, and services

An ECS task definitionThe JSON configuration describing the containers and resources for an application. describes how to run an application in containersAn isolated process that runs an application packaged with its dependencies., which package code and its dependencies. A task is a running copy; a service keeps the requested number of copies available.

How it works

  1. Write a DockerfileA file of instructions describing how to build and start an image., the instructions for building an imageA package used to create containers with application code and its dependencies.. Use docker build, test it with docker run, then use docker tag and push the image to an ECR repository, a store for container images.
  2. Reference that image in a JSON task definition. Group containers that run together and set their CPU, memory, networking, logging, roles, and volumes. A volumeStorage exposed to containers through a mounted directory. exposes storage as a directory in a container.
  3. Run a standalone task for finite work, or create a service for continuous work. EventBridge rules can launch tasks for events; EventBridge Scheduler launches them on a schedule.
  4. Choose REPLICA to maintain a desired countThe number of tasks a service is configured to maintain.. On eligible container instances, DAEMON places one task per instance. Fargate does not support DAEMON.
  5. For a service, ECS replaces stopped tasks. StopTask stops the selected task without reducing the service’s desired count.

Image layersA read-only part of an image built from a Dockerfile instruction. are read-only. The container adds a disposable writable layerThe private changeable storage added to a container and discarded when it is replaced., so changes there disappear when the container is replaced. Choose storage deliberately:

Storage Use
EFS Shared persistent files for Linux tasks on EC2 or Fargate
EBS Block storage; service-task volumes are ephemeral, standalone-task volumes can persist
S3 Files File-system access to S3 data; requires a task roleAn assumable identity that supplies temporary credentials for allowed AWS operations. and encryption in transit
Bind mount Temporary files shared by containers in the same task

S3 Files launched in April 2026.

A Fargate service can use an Application Load Balancer for HTTP/HTTPS, a Network Load Balancer for TCP/UDP, or a Gateway Load Balancer for virtual appliances such as firewalls. Classic Load Balancers are unsupported. Fargate requires awsvpc networking, which gives each task a network interfaceThe network connection associated with a task that uses awsvpc networking., its connection to the network. Use ip targets for load balancer target groupsA logical set of destinations that receive routed load balancer traffic..

Exam cues

  • If the question says a nightly ECS job must exit when done, think scheduled standalone task, because a service maintains continuous task availability.
  • If the question says stopping an ECS service task creates another, think desired count, because the service replaces stopped tasks.
  • If the question says replacement Linux tasks need the same shared files, think EFS, because container writable layers do not persist.

Remember

  • A task definition groups containers and their runtime settings.
  • DAEMON means one task per eligible instance; Fargate requires REPLICA for services.
  • EFS on Fargate Linux requires platform version 1.4.0 or later.
  • Containers share the host kernel; VMs each run a guest operating system.

Trap: Stopping a service task does not stop the service from maintaining its desired count.

A service replaces a stopped task
12ECS servicemaintain desired countStopped taskStopTask or failureReplacement taskrestore desired count
  1. A service task stops or fails.

  2. The service scheduler launches a replacement to maintain its desired count.

From the AWS docs (29)
  • A task definition is a JSON description of the containers and settings used to run an application.
  • Task definitions specify container images, CPU, memory, networking, logging, volumes, and an application IAM role.
  • A task is an instance of a task definition inside a cluster.
  • A service maintains its desired task count and replaces failed or stopped tasks.
  • Standalone tasks suit batch jobs and work that runs once rather than continuously.
  • EventBridge rules can target ECS tasks, and EventBridge Scheduler can start tasks on a schedule.
  • StopTask stops the specified running task.
  • REPLICA maintains a desired task count across a cluster.
  • DAEMON places one task on every eligible active container instance and is unsupported on Fargate.
  • A Dockerfile describes an image build; docker build builds an image, docker run starts it, and docker tag names it for a registry.
  • An image can be tested locally, tagged with an ECR repository URI, and pushed to ECR for a task definition to reference.
  • Image layers are read-only; each container adds its own writable layer.
  • Changes in a container writable layer do not survive container replacement; persistent data needs external storage.
  • EFS provides shared persistent file storage for Linux tasks on EC2 and Fargate.
  • Fargate Linux supports EFS starting with platform version 1.4.0.
  • An S3 Files volume mounts a file-system interface to S3 bucket data using s3filesVolumeConfiguration.
  • S3 Files volumes require a task IAM role and enforce encryption in transit.
  • EBS task volumes support EC2 and Fargate; service-task volumes are ephemeral, while standalone-task volumes can persist.
  • Bind mounts can share files between containers in a task and are an ephemeral storage option.
  • Fargate services support Application, Network, and Gateway Load Balancers.
  • Application Load Balancers route HTTP/HTTPS; Network Load Balancers route TCP/UDP; Gateway Load Balancers serve virtual appliances.
  • Classic Load Balancers are not supported for Fargate services.
  • Fargate requires awsvpc networking; its tasks have an elastic network interface.
  • Fargate service load balancer target groups must use ip targets rather than instance targets.
  • Containers package an application with the dependencies needed to run it.
  • A task volume exposes a storage location to its containers.
  • Amazon S3 Files launched in April 2026.
  • A container definition can reference an image by digest (repository@sha256:...), so every task runs exactly that image.
  • Containers use the host operating system kernel directly, while each virtual machine runs its own guest operating system.

Service auto scaling

ECS Service Auto Scaling adjusts how many tasks a service should run as demand changes. Application Auto Scaling manages this task count; EC2 instance capacity is managed separately through capacity providers.

How it works

  1. Set service minimum and maximum capacity, the allowed task-count bounds, and choose a scaling policy.
  2. For target tracking, select a metric and target. Application Auto Scaling manages alarms and changes capacity to approach that target. ECS publishes CPU and memory metrics every minute.
  3. For queue workers, measure backlog per taskThe queued work available for each running worker task., the queued work divided across workers. Use a custom SQS metric to scale with that work.
  4. Allow a cooldownA waiting period that gives a scaling activity time to take effect., a wait for a prior change to take effect. Scale-outAdd tasks or instances to handle more work. can interrupt a scale-inRemove tasks or instances when less capacity is needed. cooldown when demand rises.
Policy Trigger
Target tracking Keep a metric near a target
Step scaling Apply an adjustment based on an alarm breach
Scheduled Change capacity at a specified date and time
Predictive Anticipate recurring patterns from historical load

Exam cues

  • If the question says an ECS service should maintain average CPU near a target, think target tracking, because it manages the alarms and adjustments.
  • If the question says SQS worker demand depends on queued work, think backlog per task, because it relates outstanding work to workers.
  • If the question says one of several target tracking policies requests scale-out, think scale-out can proceed, because any policy can request it.

Remember

  • Minimum capacity 0 permits scale to zero; scaling out from zero needs a demand data point.
  • Target tracking does nothing with insufficient metric data.
  • With multiple target tracking policies, any may request scale-out; all enabled scale-in policies must agree to scale in.
  • ALBRequestCountPerTarget target tracking is unsupported for blue/green deployments.

Trap: Increasing desired task count does not itself add EC2 hosts. A managed capacity provider scales the instances.

From the AWS docs (14)
  • ECS Service Auto Scaling uses Application Auto Scaling to change the desired number of service tasks.
  • ECS publishes service average CPU and memory metrics for scaling.
  • ECS sends its scaling metrics to CloudWatch at one-minute intervals.
  • Target tracking chooses a metric target and manages the alarms and task-count adjustments automatically.
  • Step scaling changes task count using configured adjustments based on the size of an alarm breach.
  • Scheduled scaling changes service capacity based on a date and time.
  • Predictive scaling uses historical load to identify daily or weekly traffic patterns.
  • SQS worker services can scale using a custom backlog-per-task metric.
  • A minimum capacity of 0 permits scale to zero; target tracking waits for a demand data point before scaling out from zero.
  • A cooldown is a wait for a scaling activity to take effect; scale-out can interrupt a scale-in cooldown.
  • Target tracking takes no scaling action when the metric has insufficient data.
  • With multiple target tracking policies, any policy can request scale-out; scale-in requires every policy with scale-in enabled to agree.
  • ALBRequestCountPerTarget target tracking is unsupported for the blue/green deployment type.
  • EC2 cluster auto scaling uses a managed Auto Scaling group capacity provider to change instance capacity.

Capacity providers

A capacity provider connects ECS task demand to the compute that runs it. For EC2, managed scaling adjusts an Auto Scaling groupA collection of EC2 instances whose count can change to provide the needed capacity., the collection of hosts that can grow or shrink as tasks need capacity.

How it works

  1. Associate an Auto Scaling group capacity provider with the ECS cluster. Use it in the service’s capacity provider strategyRules defining how tasks are distributed among available capacity providers., the task distribution rules across providers.
  2. Satisfy base, a minimum task count assigned to one provider. Distribute remaining tasks by weight, a relative share. BaseA minimum task count placed on one provider before weighted task distribution. defaults to 0; at least one weightA relative share of tasks assigned to a capacity provider after satisfying its base. must be positive.
  3. Enable managed scaling so ECS adjusts the Auto Scaling group as tasks need EC2 capacity. Keep MaxSize above 0 so the group can grow.
  4. Set targetCapacity below 100% when tasks need spare host capacity.

A cluster can contain ASG and Fargate providers, but one strategy cannot mix those types. FARGATE_SPOT uses spare capacity for work that tolerates interruption. It gives a two-minute warning; unavailable Spot capacity does not automatically fall back to on-demand capacity.

Exam cues

  • If the question says ECS service scale-outAdd tasks or instances to handle more work. leaves tasks waiting for EC2 resources, think managed capacity provider, because desired task count and host count are separate controls.
  • If the question says a strategy needs a minimum task count on one provider, think base, because ECS meets it before distributing by weight.
  • If the question says tasks should start without waiting for hosts, think a target below 100%, because it retains spare capacity.

Remember

  • base defaults to 0; at least one provider weight must be positive.
  • A group that cannot grow can leave tasks in PROVISIONING.

Trap: Fargate Spot does not promise automatic on-demand replacement when Spot capacity is unavailable.

Task demand becomes EC2 capacity
12ECStask demandEC2 Auto Scalingmanaged policyEC2 instancesregister with cluster
  1. ECS managed scaling adjusts the Auto Scaling group desired capacity from task demand.

  2. The group launches instances that register with ECS to host waiting tasks.

From the AWS docs (11)
  • An Auto Scaling group capacity provider connects ECS task placement with EC2 instance capacity.
  • Managed scaling lets ECS control the Auto Scaling group using a target tracking policy and CloudWatch alarms.
  • The Auto Scaling group MaxSize must exceed 0 to allow scale-out.
  • If an Auto Scaling group cannot grow to accommodate tasks, tasks cannot progress beyond PROVISIONING.
  • Associate a capacity provider with the cluster before using it in a capacity provider strategy.
  • A strategy base places a minimum number of tasks on one provider before weight distribution; base defaults to 0.
  • Strategy weight controls relative task distribution after base; at least one provider must have positive weight.
  • A cluster can have both ASG and Fargate capacity providers, but a strategy cannot mix those two provider types.
  • FARGATE_SPOT uses spare capacity and gives a two-minute interruption warning.
  • Fargate does not automatically replace unavailable Spot capacity with on-demand capacity.
  • A targetCapacity below 100% retains spare instance capacity for future tasks.

ECS Anywhere

ECS Anywhere extends an ECS cluster to servers you own: the same task definitionsThe JSON configuration describing the containers and resources for an application. and console, with the containersAn isolated process that runs an application packaged with its dependencies. running on premises.

How it works

  1. Register an on-premises server or VM with Systems Manager and the ECS cluster (the install script adds the SSM and ECS agents).
  2. ECS schedules tasks on it with the EXTERNAL launch type.

Exam cues

  • If the question says run ECS tasks on premises with one control plane, think ECS Anywhere.
  • If the question says on-premises tasks must receive load-balanced inbound traffic, ECS Anywhere is a poor fit.

Remember

  • External instances join an existing ECS cluster.
  • No service load balancing; best for outbound or processing work.

Trap: ECS Anywhere and EKS Anywhere differ: ECS Anywhere keeps the AWS-managed ECS control plane, while EKS Anywhere puts the Kubernetes control plane on your hardware.

From the AWS docs (2)
  • Amazon ECS Anywhere registers external instances, such as on-premises servers or virtual machines, to an Amazon ECS cluster.
  • ECS Anywhere external instances suit applications that generate outbound traffic or process data, because service load balancing isn't supported for them.

Flashcards

tap to flip
Answer

·

All 22 cards as a list

How do an ECS task definition, task, and service differ?

Definition: container configuration. Task: an instance of it. Service: maintains the desired task count. Fargate supports REPLICA, not DAEMON.

An ECS service task is stopped with StopTask, but another task appears. Why?

The service replaces stopped tasks to maintain its desired count. StopTask stops a task; it does not reduce the service desired count.

A nightly container job on ECS must finish and exit. How should it run?

Use an EventBridge Scheduler schedule to launch a standalone task. A continuously maintained service is suited to long-running work.

How do you prepare a container image for an ECS task definition?

Write a Dockerfile, build and run the image locally, tag it with the ECR repository URI, and push it. Reference the image in the task definition.

Two Linux ECS tasks on Fargate must share files after either task is replaced. Which storage fits?

Use an EFS volume. It provides shared persistent storage; the container writable layer is disposable. Fargate Linux requires platform version 1.4.0 or later.

An ECS application needs file operations on data held in an S3 bucket. Which volume option fits?

Use S3 Files with s3filesVolumeConfiguration. Configure a task IAM role; encryption in transit is mandatory.

Will an EBS volume attached to an ECS service task automatically preserve application data after that task ends?

No. EBS volumes attached to service tasks are ephemeral. Standalone-task volumes can persist; EFS is shared persistent file storage.

Which load balancer should an ECS Fargate HTTP service use for application routing?

Use an Application Load Balancer. Fargate also supports Network Load Balancers for TCP/UDP and Gateway Load Balancers for virtual appliances.

An ECS Fargate service is configured with an instance-type load balancer target group. What should change?

Use ip targets. Fargate tasks require awsvpc networking and have their own network interfaces. Classic Load Balancers are unsupported.

Does replacing an ECS container preserve changes made to the image layers or its writable layer?

Image layers are read-only. The container writes into its own disposable layer; those changes do not survive replacement. Store persistent data in an appropriate external volume.

How can an ECS task definition guarantee that every task runs the exact same image, even if a tag is moved?

Reference the image by digest (repository@sha256:...) instead of by tag.

Why do containers start faster and use fewer resources than virtual machines?

Containers share the host operating system kernel; a virtual machine runs a full guest operating system.

How can an ECS service scale its task count automatically?

Use Application Auto Scaling with target tracking, step, scheduled, predictive, or SQS backlog-per-task scaling. A minimum capacity of 0 permits scale to zero.

An ECS worker service processes SQS messages with variable backlog. What scaling metric fits?

Use a custom backlog-per-task metric so capacity responds to queued work per worker.

An ECS service has CPU and memory target tracking policies. CPU requires scale-out but memory does not. What happens?

The service can scale out when either policy requests it. Scale-in requires agreement from all target tracking policies with scale-in enabled.

An ECS target tracking metric has insufficient data. Will ECS interpret that as low load and remove tasks?

No. Target tracking takes no scaling action for insufficient metric data.

An ECS EC2 service scales out but tasks remain pending for host resources. What capacity control is needed?

Use an Auto Scaling group capacity provider with managed scaling, and check its MaxSize and task fit. Service auto scaling changes task count; the capacity provider supplies hosts.

An ECS Fargate Spot service cannot obtain capacity. Will Fargate automatically run those tasks on demand?

No. Fargate does not automatically replace Spot capacity with on-demand capacity. Spot tasks receive a two-minute warning when interrupted.

An ECS team needs spare EC2 hosts so tasks can start without waiting for instance launches. What setting helps?

Set capacity provider targetCapacity below 100% to retain spare instance capacity.

How does an ECS capacity provider strategy use base and weight?

Meet the single provider base first, then distribute tasks by relative weights. Base defaults to 0, and at least one provider needs positive weight.

A company wants to run containerized batch jobs on its own on-premises servers but manage them from the same Amazon ECS control plane as its cloud tasks. Which feature fits?

Amazon ECS Anywhere, which registers on-premises servers as external instances in an ECS cluster.

Can an ECS service on ECS Anywhere external instances sit behind an Application Load Balancer?

No. Service load balancing isn't supported for external instances, so they suit outbound or data processing workloads.

You finished every topic of SAA-C03!

Your badge turned gold. Next step: book the exam on AWS. Once you pass, add yourself to Who passed.

Share

Share that you finished this certification

I finished every topic of AWS Certified Solutions Architect - Associate (SAA-C03) on Easy Review. Come study too!