LearningTree Β· AWS Β· Compute

Compute Services β€”
Running Applications in the Cloud

EC2, Lambda, ECS, Elastic Beanstalk β€” four ways to run code in AWS, each trading control for convenience differently. This page maps the full compute landscape before you dive into each service.

01
Chapter One

What is Compute?

Compute services are the core of cloud computing β€” they let you run applications, process data, and execute workloads without managing physical servers.

Every application you build needs compute: a web server answering HTTP requests, a Lambda function processing an S3 upload, a container running a microservice. AWS provides multiple compute models so you pick exactly how much infrastructure you want to own vs. hand off to the platform.

What Does Compute Mean?

Compute = running code or applications. Whenever your application is doing work β€” serving a request, processing a file, executing a job β€” it is consuming compute.

🌐

Examples of Compute Workloads

  • Web servers serving HTTP requests
  • Backend APIs handling business logic
  • Batch jobs processing files overnight
  • Event-driven functions reacting to queue messages
  • ML inference serving model predictions
⚑

What Changes Between Services

  • How much control you have over OS and runtime
  • How much management AWS takes off your hands
  • How billing works (per-hour, per-request, per-second)
  • How scaling happens (manual, scheduled, automatic)
From Fundamentals to Compute

All the fundamentals concepts you've learned feed directly into how compute services work:

πŸ“¦

Virtualization β†—

  • EC2 instances are VMs created by the Nitro hypervisor on physical AWS hosts
  • Every concept from the VM diagram applies directly here
πŸ”©

Cloud Models β†—

  • EC2 = IaaS (you manage OS and above)
  • Lambda / Beanstalk = PaaS (you manage code only)
  • The service model defines your security surface
πŸ›‘οΈ

Shared Responsibility β†—

  • On EC2 you patch the OS β€” on Lambda you don't
  • The compute model determines exactly where your responsibility begins
02
Chapter Two

Services & Spectrum

Core Compute Services
Compute Categories
CategoryServicesYou ManageBest For
Virtual MachinesEC2OS, runtime, patching, scalingFull control, GPU, custom setups
ContainersECS, Fargate, EKSContainer image, task configMicroservices, portable workloads
ServerlessLambdaFunction code onlyEvent-driven, short tasks, scale-to-zero
PaaSElastic Beanstalk, App RunnerApplication code + configStandard web apps, rapid deployment
Batch ProcessingAWS BatchJob definitions, queuesETL, HPC, scientific computing
The Compute Spectrum β€” Control vs Simplicity

Every compute service trades control for simplicity. More control = more responsibility. More abstraction = less to manage but less flexibility.

← More control / more responsibility Less management / more abstraction β†’
EC2
You own the OS
ECS
You own the container
Fargate
Container, no servers
Beanstalk
You own the app
Lambda
You own the function
Responsibility Shift Diagram
AWS Compute β€” What YOU manage vs what AWS manages per service
EC2 ECS / FARGATE BEANSTALK LAMBDA App Code Runtime OS / Patches Container LB / Scaling Hypervisor Hardware YOU YOU YOU AWS AWS AWS AWS YOU YOU AWS (Fargate) YOU AWS AWS AWS YOU AWS AWS AWS AWS AWS AWS YOU AWS AWS AWS AWS AWS AWS You manage AWS manages More abstraction β†’
03
Chapter Three

Decision Guide

When to Use What
Use EC2 when…
  • Full OS-level control needed
  • GPU or bare-metal requirements
  • Custom AMI / kernel tuning
  • Long-running persistent workloads
  • Steady-state cost optimization (RI/SP)
Use ECS / Fargate when…
  • Docker-based microservices
  • Long-running containers (always-on)
  • More runtime control than Lambda
  • Zero server management (Fargate)
  • Independent scaling per service
Use Lambda when…
  • Event-driven execution
  • Short-lived functions (<15 min)
  • Scale-to-zero matters
  • Zero server management
  • Spiky or unpredictable traffic
Use Beanstalk when…
  • Standard web app (Node/Java/Python)
  • Fastest path from code to production
  • Don't want to configure infra
  • Still need access to resources
  • Prototypes, internal tools
Full Service Comparison
ServiceTypeScalingStartupMax RuntimeBilling
EC2IaaS (VMs)ASG (manual config)1–3 minUnlimitedPer second
ECS (EC2)ContainersService Auto Scaling30–60sUnlimitedEC2 cost
ECS (Fargate)Serverless containersAutomatic30–60sUnlimitedvCPU + memory/sec
LambdaServerless functionsPer-request (instant)100ms–3s15 min maxPer ms + requests
BeanstalkPaaSBuilt-in ASG2–5 minUnlimitedUnderlying resources
EKSManaged K8sK8s HPA/Karpenter30–60sUnlimited$72/mo + nodes
App RunnerFully managedRequest-based auto~30sUnlimitedvCPU + memory
BatchJob schedulerQueue-based auto1–3 minUnlimitedUnderlying compute
04
Chapter Four

Architecture Patterns

Common Production Patterns

Most production architectures combine a traffic entry point, a compute service, and a data layer. Here are the three most common patterns:

⚑

Pattern 1: Serverless API

API Gateway β†’ Lambda β†’ DynamoDB
  • Zero servers to manage
  • Scale to zero (no idle cost)
  • Best for: event-driven APIs, microservices
🐳

Pattern 2: Container Service

ALB β†’ ECS Fargate β†’ RDS
  • Long-running, always-on
  • Docker-based (portable)
  • Best for: web apps, APIs, microservices
πŸ–₯️

Pattern 3: Traditional Web App

ALB β†’ EC2 (ASG) β†’ RDS
  • Full control over everything
  • Custom OS and runtime
  • Best for: legacy apps, GPU, full control
How Compute Fits in the Architecture
🌐
User Request
Browser Β· Mobile Β· API
β†’
βš–οΈ
Load Balancer
ALB / API Gateway
β†’
⚑
Compute
EC2 Β· Lambda Β· ECS
β†’
πŸ’Ύ
Storage / DB
S3 Β· RDS Β· DynamoDB
05
Chapter Five

Exam Insights

Exam Decision Hints
If the question says…Think…
"Least operational overhead" + containersECS + Fargate
"Event-driven" or "scale to zero"Lambda
"Kubernetes" or "multi-cloud"EKS
"GPU" or "custom AMI"EC2
"Deploy code quickly" + "standard web app"Elastic Beanstalk
"Batch processing" or "ETL jobs"AWS Batch
"Simplest container deploy" + "no infra"App Runner
"15-minute timeout" as a constraintNot Lambda β€” use ECS or EC2
"No servers" + "containers"Fargate
"Cost-optimize steady 24/7 workload"EC2 with Reserved Instances
Common Exam Traps
TrapReality
"Lambda is always cheapest"Only for spiky/infrequent workloads. Steady-state 24/7 = EC2 with RI is cheaper.
"Fargate supports GPU"NO. GPU requires EC2 launch type (P/G instance families).
"Beanstalk is just EC2"It's PaaS β€” EC2 + ALB + ASG + CloudWatch + CloudFormation, automated.
"ECS control plane costs money"ECS control plane is free. EKS charges ~$72/month per cluster.
"Serverless means no servers"Servers exist β€” AWS manages them. "Serverless" = you don't see or manage them.
Summary
πŸ“‹ Compute Services β€” Recap
  • Compute = running code. Any active workload consumes compute.
  • Core services: EC2 (IaaS), ECS/Fargate (containers), Lambda (serverless), Beanstalk (PaaS). Plus: EKS, App Runner, Batch.
  • The spectrum trades control for simplicity β€” EC2 (max control) β†’ Lambda (max abstraction).
  • Start with the simplest service that meets your needs. Graduate to more complex only when required.
  • Most architectures combine multiple models β€” Lambda for events, ECS for APIs, EC2 for legacy.
πŸ‘‰ Key Takeaway

Don't pick the "most powerful" compute service β€” pick the one that minimises management without sacrificing what your workload actually needs. Start simple, add complexity only when you hit a real limitation.