Skip to main content
In this lesson we cover resiliency considerations for Amazon Elastic Container Service (ECS) and Amazon Elastic Kubernetes Service (EKS). We start with ECS (including Fargate and EC2 launch types), then move to EKS, highlighting how core concepts and topology choices affect availability, fault tolerance, and operational complexity.

Amazon ECS: Launch types and trade-offs

ECS supports two primary launch types:
  • EC2 launch type — you run container tasks on EC2 instances that you manage (self-managed or AWS-managed node groups).
  • Fargate launch type — serverless containers where AWS manages the underlying compute.
Fargate reduces infrastructure overhead and improves isolation and security, making it a strong choice for many applications that fit its constraints. EC2 launch types offer more control (custom AMIs, larger instance types, advanced right-sizing and autoscaling), which can be more cost-effective at scale but require managing the host layer.
Choose Fargate for a serverless, low‑ops experience; choose EC2 when you need host-level control, custom instance types, or specialized networking and storage.
ECS also supports managed and unmanaged EC2 options (for example via capacity providers), and AWS continues to add higher-level automation across container offerings.

Quick comparison

Task definitions and services

A task definition is the blueprint that describes how one or more containers run together as a task. Typical fields include container images, CPU/memory, environment variables, logging, networking mode, ports, and IAM roles. Services run tasks from a task definition and maintain the desired task count, health checks, and deployment behavior.
A diagram showing a Task Definition arrowing to Amazon ECS (Fargate), which contains Service A (two task/container icons) and Service B (one task/container icon).
Running multiple services in a single ECS cluster lets you:
  • Isolate applications and failures,
  • Scale services independently,
  • Deploy updates with minimal blast radius,
  • Optimize resource utilization.
Many resiliency controls—desired counts, health checks, and deployment options—are configured at the task definition and service level.

Service healing and integrations

ECS services are self-healing: the scheduler monitors task health and replaces failed tasks to maintain the desired count. This behavior is analogous to how an Auto Scaling group replaces terminated EC2 instances. ECS frequently integrates with:
  • Elastic Load Balancers (ALB/NLB) to distribute traffic,
  • Auto Scaling Groups (ASGs) for EC2 capacity management,
  • AWS CloudWatch for metrics and alarms.
A diagram of an AWS ECS architecture showing an Elastic Load Balancer receiving user traffic and forwarding it to container tasks in an ECS cluster. An Auto Scaling Group (ASG) tied to CloudWatch for monitoring sits behind the cluster, all inside a VPC.

Placement strategies

ECS placement strategies affect how tasks are scheduled across instances: Binpack is useful for minimizing instance count and cost on EC2. Spread or random placement improves fault isolation across hosts and AZs.
A diagram titled "ECS Placement Strategies" showing how a Task Definition is placed into ECS with EC2 instances. It illustrates three strategies—Binpack, Random, and Spread—using EC2 boxes with colored container icons.

CI/CD and deployment resilience

A typical AWS CI/CD flow:
  • Source: Git repository (AWS CodeCommit, GitHub, Bitbucket).
  • Build: AWS CodeBuild or another CI system.
  • Deploy: AWS CodeDeploy or pipeline to ECS.
  • Artifact registry: Container images stored in Amazon ECR or another registry.
The deployment system pulls container images and launches tasks according to the task definition.
A CI/CD pipeline diagram showing a developer pushing code to AWS CodeCommit, which triggers AWS CodeBuild and AWS CodeDeploy to build and deploy artifacts to AWS ECS. Below that, an ECS with Fargate section depicts Service A running multiple container tasks that are launched during deployment.

Deployment safety: Circuit breaker and rollout strategies

ECS provides deployment safety features, including a deployment circuit breaker that monitors the health of newly launched tasks and can stop a rollout and roll back if health deteriorates. Combine this with deployment strategies like linear, canary, blue/green, or in‑place deployments to minimize blast radius.
A flow diagram titled "ECS Circuit Breaker Flow Diagram" showing a decision on "Tasks Status" that branches to "Tasks Healthy" (normal Amazon ECS tasks) or "Tasks Failing" (stop rollout and rollback to previous version), with container/task icons and Amazon ECS logos.

EKS runs Kubernetes control plane managed by AWS; you manage worker nodes unless you use Fargate for pods. Core Kubernetes concepts that affect resiliency:
  • Pod — smallest deployable unit, typically one application container plus optional sidecar/init containers.
  • Deployment — declares desired replica count and manages rolling updates via ReplicaSets.
  • ReplicaSet — ensures a specified number of pod replicas are running.
Most users define Deployments; the Deployment controller creates and manages ReplicaSets automatically. When running EKS, pods can run on:
  • Fargate — each pod runs in an AWS-managed, isolated compute environment.
  • EC2 nodes — pods are scheduled onto EC2 instances managed via node groups or self-managed nodes.
A slide titled "EKS Launch Type" showing "EKS with Fargate." Inside a large green outline are four pod boxes, each containing an orange container icon.
With EC2 nodes, multiple pods share the same host; with Fargate each pod gets an isolated runtime managed by AWS, simplifying operations and improving isolation at the pod level.

Cluster topology and Availability Zones

To achieve high availability, distribute nodes and pods across multiple Availability Zones (AZs). Use managed node groups or self-managed nodes as appropriate. Also distribute load balancers (ALB/NLB) and NAT Gateways across AZs.
A diagram of an Amazon EKS cluster inside a VPC showing three Availability Zones with subnets, each containing worker nodes and pods. It also shows network components like Network Load Balancers and NAT Gateways distributed across the AZs.

Resiliency layers

Think about resiliency layers from the container outward: container → pod → replicas → node → Availability Zone → cluster → region Each layer reduces failure blast radius and increases redundancy.
A diagram titled "Resilience Layers in Kubernetes" with an orange container icon at the center. Nested green rectangles label resilience levels from Container and Pod up through Replicas, Multi-Node, Multi-AZ, Multi-Cluster, to Multi-Region.

Example: single-node deployment risk

If all pods run on a single node within one AZ, the Deployment controller will restart pods if they crash — but it cannot protect against node or AZ failures. Distribute nodes and replicas across multiple AZs to maintain availability during infrastructure failures.
A diagram titled "Resilience at Availability Zone Level" showing an Amazon EKS cluster spread across two availability zones (AZ1 and AZ2) with nodes hosting Kubernetes pods and a deploy icon. Icons include EKS/AWS, node and pod symbols, illustrating multi‑AZ resilience.

Cluster-level and multi-cluster redundancy

To protect against control plane or entire-region outages, teams may deploy multiple clusters (for example, cluster-per-region) and route traffic using global routing solutions such as Amazon Route 53 or AWS Global Accelerator. Regional or global load balancing with health checks enables regional failover and disaster recovery. Running active-active clusters across regions increases cost and complexity but provides the strongest DR posture for critical workloads.
A simplified AWS architecture diagram titled "Resilience at Cluster Level" showing users routed through Route 53 and Global Accelerator to Network Load Balancers that send traffic to multiple Amazon EKS clusters, each with an ingress controller and pods. The diagram illustrates multi-cluster redundancy for high availability.

Autoscaling and provisioning

When pods cannot be scheduled due to insufficient node capacity, cluster-level provisioning tools can add capacity automatically:
  • Cluster Autoscaler — reacts to pending pods and interacts with cloud provider autoscaling APIs (e.g., AWS ASG) to add or remove EC2 nodes.
  • Karpenter — an open-source provisioner that can quickly launch right-sized instances, consider multiple instance types, and optimize packing and cost. Karpenter reacts to unschedulable pods and provisions nodes tailored to their resource needs.
A diagram titled "Kubernetes Cluster Autoscaler" showing several pods on a node with an extra pod stuck in a pending state due to insufficient resources. The Cluster Autoscaler triggers AWS Autoscaling to provision a new node.
Karpenter adds flexibility by selecting instance types, packing workloads efficiently, and supporting custom scheduling policies — often improving performance and lowering cost compared to simpler autoscaling approaches.
A diagram titled "Cluster Autoscaling Using Karpenter" showing Kubernetes pod icons, a scheduler, existing node capacity, and the Karpenter component. It illustrates how Karpenter provisions additional node capacity to place pending or unschedulable pods.
Karpenter can be a cost-effective alternative when you want control over instance selection and scheduling logic; managed autoscaling options may be preferable if you want less operational overhead.

Summary and design checklist

  • ECS:
    • Choose Fargate when you want serverless containers and reduced operational overhead.
    • Choose EC2 when you need host-level customization or complex cost optimization.
    • Use task definitions and services to control desired counts, health checks, and deployment behavior.
    • Leverage placement strategies and autoscaling to balance cost and fault tolerance.
  • EKS:
    • Understand pods, Deployments, and ReplicaSets; prefer Deployments for updates and scaling.
    • Run pods on Fargate for per-pod isolation or on EC2 for consolidated workloads.
    • Spread nodes and pods across AZs; consider multi-cluster or multi-region for DR.
    • Use Cluster Autoscaler or Karpenter to automatically provision capacity for unschedulable pods.
Both ECS and EKS integrate with CI/CD pipelines, load balancers, CloudWatch metrics, and autoscaling. Design your architecture considering failure domains (container → pod → node → AZ → cluster → region) and choose the tooling that matches your operational model and resiliency requirements.

Watch Video