SkarpSkarp

Chapter 5 of 10

Compute Services and Deployment Models in the AWS Cloud

Tour the AWS compute landscape—from virtual machines to serverless—and see how different deployment and operation models show up in both real projects and CLF-C02 scenarios.

15 min readen

1. Orienting Yourself in the AWS Compute Landscape

The Compute Spectrum

AWS compute options form a spectrum of how much you manage vs how much AWS manages, from EC2 at one end to serverless options like Lambda at the other.

Three Big Buckets

1) Self-managed on AWS: EC2. 2) Managed platforms: ECS, EKS, Elastic Beanstalk. 3) Fully managed/serverless: Lambda, Fargate, App Runner.

Paying for Compute

Instance purchasing and commitment options: On-Demand (no commitment), Reserved Instances/Savings Plans (1–3 year commitment), and Spot (spare capacity, interruptible).

Two Key Questions

Always ask: 1) How much do I want to manage vs offload to AWS? 2) How predictable is my workload and budget? These guide both real designs and CLF-C02 answers.

2. Core AWS Compute Services at a Glance

EC2: Virtual Machines

Amazon EC2 provides virtual machines. You pick instance types and AMIs and manage OS patching, agents, and most configuration yourself.

Containers: ECS and EKS

Amazon ECS is AWS’s container orchestrator; Amazon EKS is managed Kubernetes. Both can run on EC2 or on the serverless Fargate engine.

Serverless: Lambda and Fargate

AWS Lambda runs code as functions without managing servers. AWS Fargate runs containers serverlessly for ECS and EKS tasks and pods.

Platforms: Beanstalk and App Runner

Elastic Beanstalk and AWS App Runner are higher-level platforms: you provide code or a container image; AWS handles deployment and scaling.

3. Deployment and Operation Models: Who Manages What?

EC2: Maximum Control

With EC2, AWS manages hardware and virtualization, but you manage OS patching, firewalls on the instance, runtimes, and most scaling logic.

Containers on EC2

ECS or EKS on EC2: AWS manages the control plane, but you manage the EC2 worker nodes that run containers, plus images and app code.

Containers on Fargate

ECS or EKS on Fargate: AWS manages servers and OS. You define task or pod specs, CPU and memory, and container images.

Serverless and Platforms

With Lambda and App Runner, AWS manages nearly everything infrastructure-related. You focus on code, configuration, and event or traffic routing.

4. Matching Workloads to Compute Services (Scenarios)

Scenario A: Spiky Jobs

Unpredictable image uploads, no interest in server management. Map this to event-driven compute with auto-scaling: AWS Lambda triggered by S3.

Scenario B: Legacy App

Legacy Java app needs custom OS config and third-party agents, runs 24/7. This calls for full VM control: Amazon EC2.

Scenario C: Containers, No Servers

Team loves Docker, dislikes server ops. Run containers on ECS with Fargate or use App Runner for containerized web apps and APIs.

Scenario D: Kubernetes Standard

Enterprise standardizes on Kubernetes. Use Amazon EKS with either EC2 worker nodes for control or Fargate for serverless nodes.

5. Instance Purchasing Options: On-Demand, Reserved, Spot, and Savings Plans

On-Demand Instances

On-Demand: pay per use, no commitment. Ideal for new, spiky, or unpredictable workloads, but has the highest cost per unit of compute.

Reserved Instances

Reserved Instances: commit to 1 or 3 years for specific instance families. Great for steady-state workloads with predictable usage.

Savings Plans

Savings Plans: commit to a dollar amount per hour for 1 or 3 years. Compute Savings Plans can cover EC2, Fargate, and Lambda with flexibility.

Spot Instances

Spot Instances: use spare EC2 capacity at deep discounts, but your instances can be interrupted. Best for fault-tolerant, flexible jobs.

6. Thought Exercise: Pick the Compute and Purchasing Model

Work through these mini-scenarios. After you decide, compare with the suggested answer.

Scenario 1: New internal API

  • A small team is piloting an internal REST API.
  • They are not sure if usage will grow or if the project will be canceled.
  • They do not want to spend time managing servers.

Your choice:

  • Compute service?
  • Purchasing model?

Suggested answer:

  • Compute: AWS Lambda behind Amazon API Gateway, or AWS App Runner if they prefer containers.
  • Purchasing: On-Demand (no long-term commitment) or standard pay-per-use for Lambda/App Runner. It is too early to lock in RIs or Savings Plans.

---

Scenario 2: Core web application with stable traffic

  • A production web app has run for 2 years with ~50 EC2 instances at stable utilization.
  • It must run 24/7 and rarely changes.

Your choice:

  • Compute service?
  • Purchasing model?

Suggested answer:

  • Compute: Amazon EC2 (already in use; stable, long-running workloads).
  • Purchasing: Reserved Instances or Savings Plans for steady-state usage to reduce cost.

---

Scenario 3: Nightly big data batch processing

  • A data team runs large Hadoop/Spark jobs every night.
  • Jobs can be re-run if interrupted.

Your choice:

  • Compute service?
  • Purchasing model?

Suggested answer:

  • Compute: Amazon EMR on EC2 or containerized jobs on ECS/EKS.
  • Purchasing: heavy use of Spot Instances for worker nodes to minimize cost, possibly mixed with some On-Demand for reliability.

As you practice, always ask: Is the workload steady or unpredictable? Fault-tolerant or not? Do they want to manage servers?

7. Quick Check: Deployment Models and Pricing

Answer this CLF-C02 style question.

A startup wants to run containerized microservices in AWS. They do not want to manage any virtual machines or operating systems. The workload is new and traffic patterns are unknown. Which combination is the MOST appropriate starting point?

  1. Amazon ECS on EC2 with 3-year Reserved Instances
  2. Amazon ECS on AWS Fargate with On-Demand pricing
  3. Amazon EC2 Auto Scaling group using Spot Instances only
  4. Amazon EKS on EC2 with 1-year Reserved Instances
Show Answer

Answer: B) Amazon ECS on AWS Fargate with On-Demand pricing

They want containers but do not want to manage servers or OS, which points to a serverless container option: ECS on Fargate. Because the workload is new and unpredictable, On-Demand pricing avoids long-term commitments. The other options either require managing EC2 instances or committing to RIs too early.

8. A Minimal Lambda Example (Seeing Serverless in Code)

You do not need to code for CLF-C02, but seeing a tiny function helps make serverless concrete.

Below is a minimal AWS Lambda function in Python that could be triggered by an API Gateway request.

```python

import json

This is the handler AWS Lambda calls.

def lambda_handler(event, context):

event: data about the trigger (for example, HTTP request)

context: runtime information (request ID, timeout, etc.)

name = event.get("queryStringParameters", {}).get("name", "world")

return {

"statusCode": 200,

"headers": {"Content-Type": "application/json"},

"body": json.dumps({"message": f"Hello, {name}!"})

}

```

Key ideas to notice:

  • You do not provision any servers here.
  • Lambda scales this function up and down based on incoming requests.
  • You pay only for the execution time and number of requests.

When you see exam questions mentioning “upload your code and let AWS handle scaling and servers”, think of this style of Lambda function.

9. Flashcard Review: Key Terms and Concepts

Use these flashcards to reinforce core ideas about compute services and deployment models.

Amazon EC2
Core AWS service that provides virtual machines in the cloud. You manage the operating system, patches, and application stack.
AWS Lambda
Serverless compute service where you run code without provisioning or managing servers. Billed per request and execution time.
Amazon ECS
AWS-managed container orchestration service for running Docker containers on EC2 instances or AWS Fargate.
AWS Fargate
Serverless compute engine for containers used with ECS or EKS. You define tasks or pods; AWS manages servers and OS.
On-Demand Instances
Pricing model with no long-term commitment. Pay for compute capacity by the hour or second, ideal for new or unpredictable workloads.
Reserved Instances / Savings Plans
Discounted pricing options in exchange for 1- or 3-year commitments. Best for steady-state, predictable usage.
Spot Instances
Heavily discounted EC2 capacity that can be interrupted by AWS. Suitable for fault-tolerant, flexible workloads like batch processing.
Elastic Beanstalk
Managed platform for web apps. You provide code; AWS handles provisioning of EC2, load balancing, and autoscaling.
AWS App Runner
Fully managed service to build, deploy, and run containerized web applications and APIs directly from source or image.
Amazon EKS
Managed Kubernetes service that runs Kubernetes control planes for you and supports worker nodes on EC2 or Fargate.

Key Terms

Container
A lightweight, standalone executable package that includes an application and its dependencies, isolated from the host system.
AWS Lambda
Serverless compute service that runs code in response to events and automatically manages the compute resources.
Amazon EC2
Elastic Compute Cloud. Provides resizable virtual machines in the AWS Cloud.
Amazon ECS
Elastic Container Service. A fully managed container orchestration service for running Docker containers.
Amazon EKS
Elastic Kubernetes Service. Managed Kubernetes control plane for running Kubernetes workloads on AWS.
Serverless
Cloud-native model where the cloud provider manages server provisioning and scaling, and you pay only for actual usage.
AWS Fargate
Serverless compute engine for containers used with Amazon ECS and Amazon EKS.
Auto Scaling
AWS capability that automatically adjusts the number of compute resources (such as EC2 instances) based on demand.
Savings Plans
Flexible pricing model that offers lower prices in exchange for a commitment to a consistent amount of compute usage (measured in $/hour) for a 1- or 3-year term.
AWS App Runner
Fully managed service to build and run containerized web applications and APIs without managing infrastructure.
Spot Instances
EC2 instances that use spare AWS capacity at steep discounts, with the risk of interruption by AWS.
Reserved Instances
EC2 pricing option with 1- or 3-year commitments for specific instance attributes, offering significant discounts.
On-Demand Instances
EC2 pricing option with no long-term commitments; pay for compute capacity by the hour or second.
AWS Elastic Beanstalk
Platform-as-a-service style offering that deploys and scales web applications automatically on AWS resources.

Finished reading?

Test your understanding with a custom practice exam on this chapter.

Test yourself