Cloud Infrastructure Fundamentals · Module 04 of 12

Compute, images, bootstrap and auto scaling

Compare VM, container, managed-container and serverless execution models, then learn images, bootstrap, instance families, lifecycle and health-driven autoscaling.

Learning objectives

By the end of this module, you should be able to:

  • Choose between scale-up and scale-out approaches.
  • Explain the role of machine images and bootstrap/user data.
  • Describe why autoscaling needs health signals and capacity limits.
  • Compare when a workload belongs on a VM, container platform, managed container runtime or serverless function.

Compute instances are replaceable capacity

Treat instances as cattle where possible: configuration should come from images, bootstrap automation and external state rather than manual login changes.

Images, user-data and bootstrap divide build-time from start-time configuration

Machine images capture a tested base. User data/cloud-init can perform lightweight instance-specific setup. Long, fragile bootstrap scripts increase launch time and failure risk.

Autoscaling requires explicit signals and bounds

Scaling policies need metrics or schedules, minimum/maximum capacity and health replacement rules. Scaling does not fix a memory leak or broken dependency by itself.

Instance families and lifecycle states shape placement and operations

Cloud providers group virtual machines into families optimized for different CPU, memory, storage, acceleration or general-purpose profiles. Select from workload measurements rather than a familiar instance name.

Instances also move through lifecycle states such as pending, running, stopping/stopped and terminated. Automation must distinguish a reversible stop from termination and account for ephemeral state.

Cloud compute is a spectrum, not just virtual machines

VMs provide operating-system control. Containers package application dependencies while sharing a host kernel. Managed container platforms can reduce node/control-plane work. Serverless functions or managed application runtimes trade infrastructure control for event-driven or application-focused operation.

The architecture question is which operational responsibilities you need to control. Use Docker Fundamentals for image/container depth and Kubernetes Fundamentals for orchestration depth; this module focuses on choosing the cloud execution model.

Worked examples

See the idea in practice.

Bootstrap sketch

#!/bin/sh
set -eu
echo "APP_ENV=production" > /etc/academy-app.env
# Fetch application from an approved immutable artifact source here.
  • Bootstrap should be idempotent or fail clearly.
  • Secrets should come from a secret service/role, not be embedded in user data.

Execution-model decision

Need guest-OS/kernel control → VM
Need portable packaged service → container
Need orchestrated long-running containers → managed Kubernetes/container platform
Need short event-driven execution → serverless function
Need application deployment with minimal infrastructure operation → managed application/PaaS
  • These are decision cues, not rigid rules.
  • Security, startup latency, networking, state, portability, team skills and cost can change the choice.
Core lab · Modes 1–2 · Concept + local simulation

Lab — Model autoscaling decisions

Goal: Simulate a simple CPU-based desired-capacity calculation locally.

Before you start

  • Python 3 only.
STEP 1

Create the scaling function

cat > /tmp/scale.py <<'PY'
def desired(current,cpu,min_n=2,max_n=6):
    if cpu > 70: return min(max_n,current+1)
    if cpu < 30: return max(min_n,current-1)
    return current
for cpu in (20,45,85,95): print(cpu, desired(3,cpu))
PY
STEP 2

Run it

python3 /tmp/scale.py
STEP 3

Test bounds

python3 - <<'PY'
exec(open('/tmp/scale.py').read().split('for cpu')[0])
assert desired(6,95)==6
assert desired(2,10)==2
print('bounds respected')
PY
STEP 4

Classify workload execution models

python3 - <<'PY'
workloads={'legacy_kernel_module':'vm','http_microservice':'container','image_resize_event':'serverless','kubernetes_platform_team':'managed_kubernetes'}
for k,v in workloads.items(): print(k,'->',v)
assert workloads['legacy_kernel_module']=='vm' and workloads['image_resize_event']=='serverless'
PY

Verify

  • High CPU increases capacity up to max.
  • Low CPU decreases capacity down to min.
  • Mid-range CPU leaves capacity unchanged.
  • You can justify at least one VM, container and serverless choice from operational requirements rather than product familiarity.

Expected outcome

  • You can explain scaling policy inputs, bounds and why hysteresis/cooldowns matter in real systems.

Diagnose / troubleshoot

  • If an autoscaling result exceeds max capacity or falls below min capacity, inspect the bounds before changing the scaling threshold.
  • If bootstrap repeatedly fails, move heavy setup into an immutable image and keep start-time configuration small/idempotent.
  • If a workload decision feels ambiguous, list required OS control, execution duration, state, portability and orchestration needs before choosing VM/container/serverless.
Real-world connection

Production scaling often combines load-balancer health, queue depth, latency or application metrics rather than a single CPU threshold.

Mode 3 · Optional AWS lab

Optional AWS — inspect compute metadata

Inspect existing instance types and lifecycle state without launching or changing instances.

Resources created

  • None — this is a read-only inspection lab.

Estimated cost / risk

  • Expected incremental resource cost: none because the supplied commands are read-only.
  • Existing resources in the account can still incur their normal charges; confirm current AWS pricing for the selected Region/account.

Prerequisites

  • Optional sandbox AWS account and AWS CLI.
  • Use a least-privilege or federated identity; do not paste long-lived access keys into course files.
AWS 1
aws ec2 describe-instance-types --max-results 5 --query 'InstanceTypes[].{Type:InstanceType,VCPU:VCpuInfo.DefaultVCpus,MemoryMiB:MemoryInfo.SizeInMiB}' --output table
AWS 2
aws ec2 describe-instances --query 'Reservations[].Instances[].{Id:InstanceId,Type:InstanceType,State:State.Name}' --output table

Verify

  • Instance-family characteristics are visible; any existing instances are shown with lifecycle state.
  • No AWS resources are created by the supplied commands.

Cleanup

  • No AWS cleanup is required because this lab creates no AWS resources.

Warnings

  • Optional only: not required for course completion or the main validator.
  • Do not run instances merely to complete this lab.
Avoid these traps

Common mistakes

  • Putting durable application state only on instance-local disks.
  • Baking credentials into images.
  • Assuming autoscaling repairs application defects.
Knowledge check

Can you explain it without looking back?

Open each answer only after you have tried to answer the question yourself.

1What is horizontal scaling?

Adding or removing instances/capacity units rather than making one instance larger.

2Why use immutable images?

They make the base runtime repeatable and easier to replace consistently.

3Why set min and max capacity?

To define availability floors and cost/safety ceilings for the autoscaler.

4Scenario: a short image-resize job runs only when an object is uploaded and does not need OS control. Which execution model should you evaluate first?

A serverless/event-driven function model, because the workload is short-lived and triggered by events; verify runtime limits and cost before implementation.

My Learning

Record your progress for this module.

Progress is saved in this browser immediately. When you sign in to My Learning, it can also sync across devices.

Not started

Attempt the core lab and knowledge checks before marking the module complete.