AWS Compute

AWS compute covers the full spectrum from bare-metal servers to fully managed serverless functions. Choosing the right compute model depends on workload characteristics: long-running (EC2), event-driven (Lambda), containerized (ECS/EKS), or batch (Batch).

Service Map

ServiceCompute ModelControlUse Case
EC2Virtual machine (bare metal available)Full controlLong-running, predictable workloads
LambdaServerless functionsNone (managed)Event-driven, spiky, short-duration
ECSDocker containers on EC2 or FargateShared responsibilityContainerized microservices
EKSKubernetes on EC2 or FargateFull K8s APIComplex container orchestration
BatchBatch jobs on managed infraJob definitionsScheduled/queued batch processing
LightsailSimple VPSSimplifiedSimple websites, dev/test

Compute Decision Tree

How long does your workload run?
  │
  ├── Short (< 15 minutes) + event-driven?
  │     YES → Lambda (serverless, pay-per-invocation)
  │     NO ↓
  │
  ├── Containerized?
  │     YES → Do you need full Kubernetes API?
  │           YES → EKS (managed Kubernetes)
  │           NO → ECS (simpler container orchestrator)
  │     NO ↓
  │
  ├── Batch/scheduled jobs?
  │     YES → Batch (managed job scheduler)
  │     NO ↓
  │
  ├── Predictable, long-running?
  │     YES → EC2 (full control, reserved pricing)
  │     NO ↓
  │
  └── Simple website/dev environment?
        YES → Lightsail (simplified, cheap)
        NO → EC2 with auto-scaling

Instance Family Overview

FamilySpecialtyUse Case
A/T/MGeneral purposeWeb servers, small databases
CCompute optimizedMedia processing, CI/CD runners
R/XMemory optimizedDatabases, in-memory caches
G/P/INFGPUML training, inference, graphics
I/DStorage optimizedHDFS, data warehousing,日志处理
HpcHigh performanceScientific computing, CFD

Architecture Patterns

Auto-Scaling Compute

ALB → Auto Scaling Group → EC2 fleet (multi-AZ)
                        → Spot instances (cheap, interruptible)
                        → On-demand (baseline)

Serverless Event-Driven

Event (S3, SNS, SQS, CloudWatch, API GW)
  → Lambda function
      → RDS (synchronous)
      → SQS (async processing)
      → SNS (fan-out)

Container Cluster

ECS/EKS Cluster
  ├── Service A (3 tasks/pods, multi-AZ)
  ├── Service B (5 tasks/pods)
  └── Service C (1 task, batch job)

  Fargate (serverless containers) or EC2 (self-managed)

AWS Services Organized by Category

Bare Metal / Virtual Machines

  • EC2 — Virtual servers (instances)

Serverless

  • Lambda — Event-driven functions

Containers

  • ECS — Docker container orchestrator (Elastic Container Service)
  • EKS — Managed Kubernetes (Elastic Kubernetes Service)

Batch / Scheduled

  • Batch — Managed batch processing

Simple

  • Lightsail — Simple VPS for basic workloads

References

Nuggets & Gotchas

  • Lambda has a 15-minute max execution time — long-running tasks need EC2 or ECS: If your workload takes > 15 minutes, use EC2 (with Auto Scaling) or ECS Tasks. Lambda is designed for short, event-driven processing.
  • EC2 Spot instances are 70-90% cheaper but can be interrupted with 2-minute notice: Use Spot for fault-tolerant workloads (batch jobs, stateless services). Don’t use Spot for databases or stateful services without checkpointing.
  • ECS and EKS both use the same underlying Docker infrastructure — EKS adds Kubernetes API: If you know Kubernetes, use EKS. If you want simpler AWS-native container management, use ECS. Both can run on EC2 or Fargate.
  • Batch and Lambda solve different problems — Batch for jobs > 15 min, Lambda for < 15 min: Batch jobs run on EC2 (or Fargate) with job queuing and scheduling. Lambda is for sub-15-minute event-driven tasks.
  • Lightsail is limited compared to EC2 — no Auto Scaling, limited instance types, no VPC peering: Lightsail is for simple use cases (WordPress, small databases). For production, use EC2 with Auto Scaling and proper networking.