AWS Cloud Practitionercore-compute-services

Core Compute Services: EC2, Lambda, and Containers

Compare EC2 instances, serverless Lambda, and container services and when to use each.

The Cloud Practitioner exam repeatedly asks you to match a workload to the right compute service and to pick the cheapest pricing model for a given usage pattern. The trick is not memorizing every feature — it is knowing how much of the stack you want to manage (a full server, a container, or nothing at all) and how predictable your usage is. Master the trade-offs below and the compute questions become pattern recognition.

Core Idea

  • Compute spans a spectrum of management. EC2 gives you full virtual servers you manage; containers (ECS/EKS/Fargate) package apps for portability; Lambda is fully serverless with no infrastructure to manage.
  • Pricing rewards predictability and flexibility. Steady, known workloads save the most with Reserved Instances or Savings Plans; fault-tolerant, interruptible work runs cheapest on Spot; unpredictable spikes fit On-Demand or Lambda.
  • Pay only for what you use. Lambda charges per invocation and duration with no idle cost, while EC2 charges while an instance runs whether busy or not.

Amazon EC2 and Instance Families

Amazon EC2 (Elastic Compute Cloud) provides resizable virtual servers (instances) in the cloud. You choose an instance type from a family tuned to a workload:

  • General purpose — balanced compute, memory, and networking for web servers and small databases.
  • Compute optimized — high-performance processors for batch processing and gaming servers.
  • Memory optimized — large in-memory datasets and high-performance databases.
  • Storage optimized — high sequential read/write to large local datasets (data warehousing).
  • Accelerated computing — GPUs for machine learning and graphics.

You are responsible for the OS, patching, scaling, and capacity — this is the most control and the most operational overhead.

EC2 Purchasing Options

Matching the pricing model to usage is the single most tested cost concept:

  • On-Demand — pay per second/hour, no commitment. Best for short-term, spiky, or unpredictable workloads and for first-time testing.
  • Reserved Instances (RIs) — commit to a 1- or 3-year term for up to ~72% savings. Best for steady-state, always-on workloads with predictable usage.
  • Savings Plans — commit to a consistent amount of compute ($/hour) for 1 or 3 years; more flexible than RIs across instance families and even Lambda/Fargate.
  • Spot Instances — use spare capacity for up to ~90% savings, but AWS can reclaim it with a two-minute warning. Best for fault-tolerant, flexible, stateless work (batch jobs, CI/CD).
  • Dedicated Hosts — a physical server dedicated to you, the most expensive option, used for strict compliance or bring-your-own-license (BYOL) needs.

Elasticity: Auto Scaling and Load Balancing

  • EC2 Auto Scaling automatically adds instances when demand rises and removes them when it falls, so you pay only for capacity you need and maintain availability.
  • Elastic Load Balancing (ELB) distributes incoming traffic across multiple instances (across Availability Zones), improving fault tolerance.
  • Together they deliver elasticity (scale to demand) and high availability (survive an instance or AZ failure). On the exam, "handle unpredictable traffic automatically and cost-efficiently" points to Auto Scaling + ELB.

Serverless with AWS Lambda

AWS Lambda runs code in response to events without provisioning or managing servers. It is event-driven (triggered by an S3 upload, API call, or schedule), scales automatically, and is billed per invocation and duration — you pay nothing when idle. Functions have a maximum execution timeout (15 minutes), so Lambda suits short, event-driven tasks, not long-running or stateful applications.

Containers and Higher-Level Options

  • Amazon ECS — AWS-native container orchestration.
  • Amazon EKS — managed Kubernetes for teams standardized on Kubernetes.
  • AWS Fargate — serverless compute engine for containers; run ECS/EKS containers without managing the underlying EC2 servers.
  • AWS Elastic Beanstalk — deploy and manage web apps by uploading code; AWS handles capacity, scaling, and load balancing (platform as a service feel).
  • Amazon Lightsail — simple, low-cost bundled virtual servers for simple websites and beginners.

High-Yield Exam Patterns

  • Steady, predictable, always-on → Reserved Instances or Savings Plans.
  • Fault-tolerant, interruptible, cheapest possible → Spot Instances.
  • Short-term, spiky, or unknown usage → On-Demand.
  • Compliance / dedicated physical hardware / BYOL → Dedicated Hosts.
  • Event-driven code with no servers to manage, pay-per-use → Lambda.
  • Run containers without managing servers → Fargate; need Kubernetes → EKS.

Common Traps to Avoid

  • Choosing Spot for a critical stateful database — Spot can be reclaimed and is only for interruption-tolerant work.
  • Picking On-Demand for a workload that runs 24/7 all year — that ignores the big savings of Reserved Instances or Savings Plans.
  • Assuming Lambda fits long-running or always-on jobs — it has a 15-minute timeout and is meant for short, event-driven tasks.
  • Confusing Auto Scaling (adds/removes instances) with Elastic Load Balancing (distributes traffic); the exam tests both roles.
  • Thinking Fargate is a container orchestrator — it is the serverless engine that runs containers for ECS or EKS.

Flashcards

Card 1 of 14

1/14

Keyboard: Space/Enter to flip • Arrow keys to navigate

Ready to Test Your Knowledge?

This quiz has 8 questions and each one has 4 options.

Quiz Details

8 Questions

Multiple choice with instant self-check

Final Review

See correct answers and explanations at the end

Build your own lesson in minutes.

Upload a source document and turn it into flashcards, quizzes, and a study-ready lesson bank.