Compute is at the heart of every cloud workload. AWS offers multiple compute services covering virtual machines, serverless functions, and containers — each suited to different use cases.
Amazon EC2 — Elastic Compute Cloud
EC2 lets you launch virtual machines (called instances) in minutes. You choose the operating system, instance type, storage, and networking configuration.
Instance Types
Instance types are organised into families based on their hardware profile:
| Family | Optimised for | Examples |
|---|---|---|
| General Purpose | Balanced CPU/memory | t3, t4g, m6i, m7g |
| Compute Optimised | High CPU | c6i, c7g |
| Memory Optimised | High RAM (databases) | r6i, x2iedn |
| Storage Optimised | High disk throughput | i4i, d3 |
| Accelerated Computing | GPUs / ML inference | p4, g5, inf2 |
EC2 Pricing Models
- On-Demand: Pay by the hour/second, no commitment. Highest per-hour cost. Best for unpredictable workloads.
- Reserved Instances: 1 or 3-year commitment. Up to 72% discount. Best for steady, predictable workloads.
- Savings Plans: Flexible alternative to Reserved. Commit to a spend level ($/hr). Covers EC2, Lambda, Fargate.
- Spot Instances: Unused EC2 capacity at up to 90% discount. Can be interrupted with 2-minute warning. Best for fault-tolerant batch jobs.
- Dedicated Hosts: Physical server dedicated to your use. Required for some software licenses (Oracle, Windows Server).
EC2 Auto Scaling
Auto Scaling Groups (ASGs) automatically launch or terminate EC2 instances based on CloudWatch metrics (e.g., CPU > 70%). Combined with an Elastic Load Balancer, this is the standard pattern for scalable, highly available web applications.
AWS Lambda — Serverless Functions
Lambda lets you run code without managing servers. You upload a function, configure a trigger, and AWS runs it — scaling automatically from zero to thousands of concurrent executions.
- Supported runtimes: Node.js, Python, Java, Go, .NET, Ruby, custom
- Maximum execution time: 15 minutes per invocation
- Memory: 128 MB – 10 GB (CPU scales proportionally)
- Pricing: billed per invocation and per GB-second of compute
Common triggers: API Gateway (HTTP), S3 events, DynamoDB streams, SQS, EventBridge, CloudWatch Events, SNS.
Use cases: REST API backends, file processing, real-time stream processing, scheduled tasks, event-driven automation.
Amazon ECS — Elastic Container Service
ECS is AWS's managed container orchestration service, designed specifically for Docker containers. You define tasks (container specs) and services (how many copies to run). ECS can run on:
- EC2 launch type: You manage the EC2 instances that run your containers.
- Fargate launch type: AWS manages the underlying compute — serverless containers.
Amazon EKS — Elastic Kubernetes Service
EKS provides a managed Kubernetes control plane. AWS handles Kubernetes version upgrades, patching, and control plane availability. You focus on deploying workloads using standard Kubernetes manifests.
EKS also supports Fargate node groups for serverless Kubernetes pods.
AWS Fargate
Fargate is a serverless compute engine for containers. It works with both ECS and EKS. You specify CPU and memory for each container; AWS provisions, scales, and manages the underlying instances. You pay only for the vCPU and memory consumed while your containers run.
Other Compute Services
- AWS Batch: Managed batch computing for large-scale jobs.
- AWS Lightsail: Simplified VMs with fixed pricing — for small projects and beginners.
- AWS App Runner: Deploy containerised web apps without infrastructure management.
- AWS Elastic Beanstalk: PaaS — upload code and Beanstalk handles deployment, scaling, and health monitoring.
The next lesson covers how AWS handles storage — the different types and when to use each.