An application can run perfectly well in development and still become difficult to operate when deployed at scale. The problem is not always the application itself. Sometimes, the selected compute model introduces unnecessary operational effort, limits flexibility, or increases costs.
AWS offers several compute services, but choosing the right one requires understanding how each workload runs and how much infrastructure management it needs.
WHAT
AWS compute services provide different execution models, from managing virtual servers and orchestrating containers to running event-driven functions without directly managing servers.
- Amazon EC2: Provides virtual servers with control over operating systems, instance types, storage, and software configurations.
- Amazon ECS: Orchestrates containerized applications using AWS-managed container orchestration. It can run tasks on EC2 or Fargate.
- Amazon EKS: Provides a managed Kubernetes control plane while allowing teams to operate Kubernetes-based workloads and their associated infrastructure.
- AWS Fargate: Provides serverless compute capacity for supported ECS and EKS workloads, removing the need to manage the underlying EC2 instances.
- AWS Lambda: Executes code in response to events without requiring direct server management. Standard Lambda function executions have a maximum duration of 15 minutes.
The important distinction is that ECS and EKS orchestrate containers, Fargate provides container compute, EC2 provides virtual servers, and Lambda follows a function-based execution model.
WHERE
Different compute models suit different application requirements.
- EC2: Legacy applications, specialized software, GPU workloads, and applications requiring operating system-level control.
- ECS: AWS-focused containerized applications, microservices, and web applications that need container orchestration.
- EKS: Kubernetes-based platforms, organizations using Kubernetes tooling, and workloads requiring Kubernetes APIs and ecosystem integrations.
- Fargate and Lambda: Fargate suits containerized applications that need serverless infrastructure management. Lambda suits event-driven processing, scheduled automation, and short-running backend tasks.
Compute pricing varies by service. EC2 and ECS on EC2 involve instance costs, Fargate charges for provisioned compute resources and usage duration, and Lambda pricing depends on requests and execution duration. Networking, storage, monitoring, and data transfer can also contribute to the total cost.
WHY
Selecting a compute service is not just about finding the lowest hourly price. It is about balancing infrastructure control, operational effort, workload behavior, and total cost.
EC2 offers greater control but requires responsibility for operating system maintenance, capacity planning, and instance management.
ECS simplifies container orchestration without requiring Kubernetes. When paired with Fargate, it also removes the need to manage the underlying servers.
EKS provides Kubernetes compatibility and flexibility, but operating Kubernetes workloads requires additional expertise and operational effort.
Lambda reduces server-management responsibilities and works well for event-driven workloads. However, execution duration, invocation volume, memory allocation, and downstream dependencies influence its suitability and cost.
Before finalizing the architecture, compare the expected workload costs using the AWS Pricing Calculator.
WHEN
Use EC2 when:
- The application requires operating system-level access or specialized configurations.
- Existing software has dependencies that make containerization difficult.
- Specialized instance capabilities are required.
Use ECS when:
- The application is already containerized or is being designed around containers.
- Container orchestration is required without adopting Kubernetes.
- A simpler AWS-native container management approach is preferred.
Use EKS when:
- Kubernetes APIs, tooling, and ecosystem integrations are important.
- The organization already has Kubernetes operational expertise.
- Kubernetes-based deployment patterns are required across environments.
Use Fargate when:
- Containers need to run without managing EC2 instances.
- Infrastructure-management overhead needs to be reduced.
- Workloads benefit from managed container compute capacity.
Use Lambda when:
- Code executes in response to events.
- Tasks are short-running and fit within Lambda's execution limits.
- Workloads have variable demand or periods of inactivity.
HOW
Consider an online store with three workloads: a website and checkout service, product image processing, and a legacy inventory application. Each workload has different compute requirements, so using one compute service for everything may not be the best design.
The website runs as containers on ECS with Fargate behind an Application Load Balancer. Product image uploads to Amazon S3 trigger Lambda functions for processing. The legacy inventory application runs on EC2 because it requires a specific operating system configuration or licensed software.
The cost trade-off depends on utilization and operational effort. EC2 can be suitable for steady workloads, while Fargate and Lambda can reduce infrastructure-management overhead for suitable workloads. The right decision should account for the complete architecture rather than compute pricing alone.
TAKEAWAY
The right AWS compute service is the one that matches each workload's execution pattern, infrastructure requirements, scaling behavior, operational constraints, and total cost.



