CloudVol. 7 · Part VII
0 / 0

Shelves / Cloud

CL·86

Compute

The cloud compute spectrum from virtual machines to functions: instance families and sizing, images and bootstrapping, the metadata service, ARM and GPU instances, spot capacity; autoscaling groups and scaling policies; containers on ECS/Fargate, Cloud Run and Azure Container Apps; managed Kubernetes (EKS, AKS, GKE and their autopilot modes); serverless functions in depth (event model, concurrency, cold starts, SnapStart, limits, Lambda Managed Instances and durable functions); managed application platforms; batch; and how to choose, with handlers in Java, Go, Python, Rust and TypeScript.

30 topics · ~22 min read · 30-question quiz
Updated Suggest a correction

Start here: how much of the machine do you want to manage?

The compute spectrum

Cloud compute comes in levels of "how much do you manage":

Option You provide Provider runs Scales Billing Examples
Virtual machines OS image, patches, runtime, app Hardware, hypervisor Instance groups Per second/hour of instance EC2, Azure VMs, Compute Engine
Managed Kubernetes Containers, manifests, nodes (or not) Control plane (and nodes, in auto modes) Pods and nodes Nodes (+ control plane fee) EKS, AKS, GKE
Serverless containers A container image Everything below it Tasks/revisions, often to zero vCPU and memory per second Fargate, Cloud Run, Azure Container Apps
Functions A handler function Everything Per request, to zero Requests + GB-seconds Lambda, Azure Functions, Cloud Run functions
Application platforms Code or a container Builds, runtime, routing Instances Instance-hours Elastic Beanstalk, App Service, App Engine

Moving right means less to operate and faster scaling, in exchange for less control (runtimes, networking, long-running work, special hardware), and a price per unit of work that is higher at constant load but zero when idle.

Cold starts: the cost of scaling from zero

Platforms that scale to zero must start a new instance when a request arrives and nothing is running: a cold start. How long that takes depends mostly on your code and runtime:

Text
Go static binary (tiffin): start to first answered request, median 4 ms
cold start (new Python process + imports + client): median 320 ms, of which boto3 import and client 216 ms
Spring Boot 4.1 minimal web app on JDK 21: Started OrderFn in 2.295 seconds (process running for 2.648)
warm invocation (same process, handler only): median 1.6 µs

A warm Python function answered in under 2 microseconds of its own time; a cold one paid a third of a second, two-thirds of it importing the AWS SDK. A Spring Boot app took over two seconds to start. On a function platform the provider adds its own time (fetching the code, starting a microVM), so real cold starts run from about 100 ms to several seconds. The remedies:

  • Keep instances warm: provisioned concurrency or minimum instances (you pay for them while idle).
  • Make start-up cheaper: fewer and lazier imports, smaller packages, initialising clients once outside the handler.
  • Use runtime features: Lambda SnapStart for Java (and Python and .NET) restores a snapshot of an initialised runtime; GraalVM native images; JVM class-data sharing and the JDK's ahead-of-time cache.
  • Choose a long-running service (containers or VMs) when latency must be predictable.

Scaling and paying

Every option scales by running more copies, but at different speeds and granularity: a VM takes a minute or more to boot and warm up; a container a second or two plus your app's start; a function instance as fast as its cold start, one concurrent request per instance (in Lambda's model). That changes the bill: functions cost nothing at zero traffic and the most per request at constant high traffic, while VMs cost the same whether busy or idle (the lab prices three traffic shapes).

How deep to go in compute

Volume 17 defines six mastery levels. For this chapter they look like this; the chapter aims at L3 everywhere, and its lab at L4.

Level What you can do
L1 Explain VMs, containers, Kubernetes services, functions and app platforms
L2 Deploy a service on each; configure instance types, autoscaling, images and roles
L3 Explain cold starts, concurrency models, instance families, pricing models and scaling signals
L4 Diagnose throttling, cold-start latency, scaling lag, spot interruptions and cost surprises
L5 Choose compute per workload with cost, latency, operations and lock-in trade-offs
L6 Run fleets with capacity planning, commitments, rightsizing and multi-architecture builds

The compute spectrum

Every compute option trades control for operational burden:

more controlless to operate VMsEC2 · Azure VMCompute Engine KubernetesEKS · AKS · GKE serverlesscontainersFargateCloud Run app platformsApp ServiceApp Runner functionsLambda · Azure FnCloud Run fn you: OS, patching, scaling, capacityyou: code + config pay per instance-second (idle costs)pay per request / GB-s (scale to zero)
The compute spectrum. Moving right, the provider manages more (OS, scaling, servers) and you manage less, but you also give up control over runtime, duration and hardware, and the pricing model shifts from paying for capacity to paying per request.

Virtual machines

Instance types

A VM's instance type fixes its vCPUs, memory, network bandwidth, local storage and accelerators. Naming encodes the trade-off. AWS: m7g.xlarge = family m (general purpose), generation 7, attribute g (Graviton ARM), size xlarge (4 vCPU, 16 GiB). Azure (Standard_D4s_v5) and GCP (n2-standard-4, c4a-standard-4 for Axion ARM) follow similar schemes.

Family (AWS / Azure / GCP) Ratio Use
General purpose (m / D / n2, e2, n4) ~4 GiB per vCPU Web services, most apps
Compute optimised (c / F / c3, c4) ~2 GiB per vCPU CPU-bound services, batch, encoding
Memory optimised (r, x / E, M / m3, n2-highmem) 8–32+ GiB per vCPU Databases, caches, JVMs with big heaps, analytics
Storage optimised (i, d / L / z3) Local NVMe Self-managed databases, search, Kafka
Burstable (t / B / e2-micro/small) CPU credits Low, spiky load; dev; beware throttling when credits run out
Accelerated (p, g, trn, inf / NC, ND / a3, g2, TPU) GPUs, AI chips ML training and inference, graphics

ARM instances (AWS Graviton 4, Azure Cobalt 100, Google Axion) typically give 20–40% better price-performance for workloads that run on ARM: Java, Go, Python, Node, .NET and Rust usually just work (build multi-arch images, chapter 81); watch for native dependencies without ARM builds.

vCPU usually means one hyperthread, so 2 vCPUs is one physical core on most x86 types (AWS Graviton vCPUs are full cores). This matters for CPU-bound sizing.

Images and bootstrapping

  • A VM boots from an image: AMI (AWS), managed image or Azure Compute Gallery image, GCE image. Use golden images built by a pipeline (Packer, EC2 Image Builder, Azure VM Image Builder) with the OS, patches, agents and runtime pre-installed: faster boots, consistent fleets, no internet dependency at boot.
  • cloud-init / user data runs scripts at first boot (install packages, write config, start services). Keep it small: slow, fragile boot scripts make autoscaling slow and failure-prone.
  • Immutable infrastructure: never patch a running fleet by hand; build a new image and replace instances (rolling instance refresh).

The instance metadata service

Every VM can query a link-local metadata endpoint (169.254.169.254) for its instance ID, region, network config, user data and, crucially, temporary credentials for its IAM role (chapter 89). Because a server-side request forgery (SSRF) bug in your app could make the server fetch those credentials for an attacker (the 2019 Capital One breach), AWS introduced IMDSv2: a session token obtained with a PUT request and a hop limit of 1, which typical SSRF can't do. Require IMDSv2 on every instance (it's the default for new instance types and launch templates in many accounts). Azure IMDS requires a Metadata: true header; GCP requires Metadata-Flavor: Google.

Shell
# IMDSv2: get a token, then use it
TOKEN=$(curl -sX PUT http://169.254.169.254/latest/api/token -H "X-aws-ec2-metadata-token-ttl-seconds: 300")
curl -s -H "X-aws-ec2-metadata-token: $TOKEN" http://169.254.169.254/latest/meta-data/placement/availability-zone-id

Other VM concepts

  • Placement groups / proximity placement: cluster (low latency, same rack area: HPC), spread (each instance on distinct hardware: small critical sets), partition (groups of racks: Kafka, Cassandra, HDFS).
  • Dedicated hosts / instances: single-tenant hardware for licensing (per-socket licences) or compliance.
  • Spot capacity: up to ~90% cheaper, reclaimable (AWS gives a 2-minute interruption notice, plus rebalance recommendations). Diversify across instance types and AZs, handle the notice (drain, checkpoint), and use capacity-optimised allocation.
  • Hibernation, stop/start: stopping releases the host (local NVMe "instance store" data is lost; EBS persists).

Autoscaling groups

An autoscaling group (AWS ASG, Azure Virtual Machine Scale Sets, GCP managed instance groups) keeps a fleet of identical VMs from a launch template at a desired size, across AZs:

  • Health checks: EC2 status checks, or load-balancer health checks (replace instances that fail the app's health endpoint).
  • Scaling policies:
  • Target tracking ("keep average CPU at 50%", "keep 1,000 requests per target"): the simplest and usually best.
  • Step scaling (alarm thresholds add or remove N instances).
  • Scheduled scaling (known daily patterns).
  • Predictive scaling (ML forecast from history, scaling ahead of daily cycles).
  • Lifecycle hooks: pause instances during launch (warm caches, register) or termination (drain connections, flush logs).
  • Warm pools: pre-initialised stopped instances that start faster than fresh ones.
  • Instance refresh / rolling replacement: roll out a new launch template version gradually with a minimum healthy percentage.
  • Mixed instances policy: combine on-demand base capacity with spot, across several instance types.
load balancer autoscaling group · launch template v7 · desired 6 → 8 AZ a new AZ b ✕new AZ c metric: CPU 72% > target 50% → scale out ✕ failed health check → replaced
An autoscaling group spread across three AZs behind a load balancer. A target-tracking policy watches a metric (CPU or requests per target) and changes desired capacity; unhealthy instances are replaced automatically from the launch template.

Containers in the cloud

Serverless containers

Run container images without managing servers or a cluster:

Service Model Notes
AWS ECS on Fargate Tasks (one or more containers) with CPU/memory sizes, in your VPC ECS is AWS's own orchestrator (services, task definitions, service discovery, ALB integration); Fargate removes EC2 management; ECS on EC2 for more control or GPUs
Google Cloud Run HTTP or event-driven containers, request-based autoscaling including to zero, concurrency per instance (default 80), jobs for batch Very fast to adopt; GPUs available; billing per request-time or instance-time
Azure Container Apps Built on Kubernetes + KEDA + Envoy (+ Dapr optional), scale to zero, revisions with traffic splitting Dedicated workload profiles for steady loads
AWS App Runner Source or image → HTTPS service with autoscaling Simplest on AWS for web apps

Container platforms suit almost every language without special adaptation (any language that builds an image), long-running and streaming requests, and teams that want portability (the same image runs locally, on Kubernetes and on Cloud Run).

Managed Kubernetes

  • EKS (AWS), AKS (Azure), GKE (Google; Kubernetes' original home, often first with new features) run the control plane for you (upgrades, etcd, HA). You choose node management:
  • self-managed node groups;
  • managed node groups (provider handles node provisioning and updates);
  • fully managed nodes: GKE Autopilot (pay per pod resource request), EKS Auto Mode (Karpenter-based provisioning, managed add-ons), AKS Automatic;
  • Fargate profiles on EKS (a pod per micro-VM).
  • You still own: workloads, add-ons (ingress/gateway, cert-manager, external-dns, observability agents), upgrades of Kubernetes versions (every ~4 months, with roughly 14 months of standard support and paid extended support), and the security of everything in-cluster.
  • Choose Kubernetes when you need its ecosystem and portability or run many services; choose ECS/Cloud Run/Container Apps when you want less platform to operate.

Serverless functions

The model

A function (AWS Lambda, Azure Functions, Cloud Run functions, formerly Cloud Functions) is code the platform runs in response to events, scaling from zero to thousands of concurrent instances, billed per invocation and per GB-second of memory-time.

Event sources (Lambda as the example; the others are similar):

Invocation type Sources Behaviour
Synchronous API Gateway, ALB, function URLs, direct Invoke Caller waits; errors returned to the caller
Asynchronous S3 events, SNS, EventBridge Lambda queues internally, retries twice on error, then sends to a dead-letter queue or failure destination
Event source mapping (poll-based) SQS, Kinesis, DynamoDB Streams, Kafka (MSK or self-managed), MQ Lambda polls and invokes with batches; partial batch failure reporting; per-shard ordering for streams

Execution environment and cold starts

cold start micro-VM(Firecracker) fetch code start runtimeJVM / Python… init codeclients, pools handler warm invocations reuse the environment handler handler frozen between invocations · reclaimed after idle SnapStart: snapshot after init; cold starts restore it instead of re-running init
Lambda execution environment lifecycle. A cold start creates a micro-VM, downloads code, starts the runtime and runs initialisation code; subsequent invocations reuse the warm environment, where only the handler runs. Idle environments are eventually reclaimed.
  • Each execution environment (a Firecracker micro-VM on Lambda) handles one request at a time; concurrent requests get more environments.
  • A cold start happens when a new environment is created: VM + code download + runtime start + your initialisation code. Typical: 100–500 ms for Node, Python, Go and Rust; seconds for unoptimised JVM or .NET apps with heavy frameworks.
  • Code outside the handler runs once per environment: create SDK clients, connection pools and config there, and they're reused by warm invocations.
  • Mitigations:
  • small packages and lazy loading;
  • fast runtimes (Go, Rust, Node, Python; GraalVM native image for Java);
  • SnapStart (Java, Python, .NET: snapshot after init, restore on cold start; mind uniqueness of random seeds and stale connections after restore);
  • provisioned concurrency (pre-initialised environments, billed while provisioned);
  • more memory (which also gives proportionally more CPU).

Limits and economics

  • Timeouts: Lambda max 15 minutes per invocation; memory 128 MB to 10 GB (CPU scales with memory, up to 6 vCPUs); payload 6 MB synchronous; /tmp up to 10 GB.
  • Concurrency: a regional account limit (default 1,000, raisable), reserved concurrency to cap or guarantee a function's share; burst scaling rates are bounded. Downstream systems (databases) must survive the fan-out: use RDS Proxy or connection pooling, and cap concurrency.
  • Cost model: very cheap at low or spiky load; at sustained high throughput, per-request pricing can exceed always-on containers. Profile both.
  • New options announced at re:Invent 2025:
  • Lambda Managed Instances run functions on EC2 instances in your account (managed by AWS), with multiple concurrent requests per environment and instance-type choice, for steady high-volume workloads.
  • Lambda durable functions add checkpointed, long-running workflows (waits up to a year for asynchronous invocations), in the spirit of durable execution engines (Vol. 5 ch. 73).

Function code across languages

// Java: Lambda handler for SQS with partial batch failure reporting; clients created once per environment
public class OrderHandler implements RequestHandler<SQSEvent, SQSBatchResponse> {
    private static final DynamoDbClient DDB = DynamoDbClient.create();   // init phase (reused, SnapStart-friendly)

    @Override
    public SQSBatchResponse handleRequest(SQSEvent event, Context ctx) {
        List<SQSBatchResponse.BatchItemFailure> failures = new ArrayList<>();
        for (SQSEvent.SQSMessage m : event.getRecords()) {
            try {
                process(m.getBody());                                      // must be idempotent
            } catch (Exception e) {
                failures.add(new SQSBatchResponse.BatchItemFailure(m.getMessageId()));
            }
        }
        return new SQSBatchResponse(failures);                             // only failed messages retried
    }
}

Azure Functions (C#, Java, JavaScript/TypeScript, Python, PowerShell, plus custom handlers for Go and Rust) uses triggers and bindings declared on the function, and hosting plans: Flex Consumption (scale to zero, VNet integration, configurable instance memory and always-ready instances), Premium, and Dedicated. Cloud Run functions are deployed onto Cloud Run, so the same concurrency and scaling model applies.

When functions fit

  • ✓ Event glue (file uploaded → process; queue message → handle), webhooks, scheduled jobs, spiky or low-traffic APIs, fan-out processing.
  • ✗ Long-running processes beyond time limits, workloads needing persistent connections or local state, steady high throughput (often cheaper on containers), very latency-sensitive paths sensitive to cold starts, heavy native dependencies.
  • Watch for: hidden coupling through many tiny functions ("Lambda pinball"), recursive invocation loops (an S3 trigger that writes to the same bucket; Lambda now detects some loops), concurrency storms against databases, and testing difficulty (run locally with SAM, LocalStack, or the Azure Functions Core Tools).

Managed application platforms

PaaS offerings run a web application from code or an image, adding scaling, TLS, deployments, logging and slots:

  • Azure App Service (web apps in .NET, Java, Node, Python, PHP, or containers; deployment slots for blue/green swaps).
  • AWS Elastic Beanstalk (older, wraps EC2 + ASG + ELB), AWS App Runner.
  • Google App Engine (largely superseded by Cloud Run for new work).
  • Developer platforms outside the hyperscalers: Heroku, Render, Fly.io, Railway, Vercel and Netlify (frontends and edge functions).

They're excellent for small teams and standard web apps; you trade away fine-grained network, runtime and cost control.

Batch and high-performance computing

  • AWS Batch, Azure Batch, Google Cloud Batch: queue jobs, provision compute (often spot), run containers to completion, scale to zero.
  • Kubernetes Jobs with Kueue for queueing and fair sharing; Argo Workflows for DAGs.
  • Spark/EMR, Dataproc, Databricks, Synapse for data processing (Vol. 4 ch. 63).
  • HPC: cluster placement, Elastic Fabric Adapter (AWS) or InfiniBand (Azure HB/ND series), ParallelCluster/Slurm.
  • Design batch jobs to be checkpointed and idempotent so spot interruptions only cost a retry.

Autoscaling across the spectrum

Platform Scales on Speed Scale to zero
VM autoscaling groups CPU, requests per target, custom metrics, schedules, predictions Minutes (boot + warm-up) Possible (min 0), slow to wake
Kubernetes (HPA + Karpenter/cluster autoscaler) Pod metrics; nodes on pending pods Pods: seconds; nodes: minutes With KEDA
ECS services Target tracking on CPU/memory/ALB requests Tens of seconds With custom tooling
Cloud Run, Container Apps Concurrent requests per instance, events Seconds Yes
Functions Each event Milliseconds to seconds Yes

General rules: scale on the metric closest to user experience (concurrency, queue age, latency) rather than only CPU; keep minimum capacity across AZs; set maximums to protect budgets and downstream systems; and load test the scaling behaviour itself (Vol. 11).

Choosing compute

If you need… Consider
Full OS control, special kernels, licensed software, stateful legacy apps VMs (with golden images and ASGs)
Many services, existing Kubernetes skills, portability, rich ecosystem Managed Kubernetes (Autopilot/Auto Mode to reduce toil)
Containers without operating a cluster ECS on Fargate, Cloud Run, Azure Container Apps
A standard web app with minimal ops App Service, App Runner, Cloud Run
Event-driven glue, spiky workloads, scale to zero Functions
Large parallel batch jobs Batch services on spot
GPUs for ML GPU VMs, Kubernetes GPU node pools (DRA), managed ML platforms (Vol. 14)

Lab: start-up, cost, scaling lag and interruptions

Experiment 1 measured real start-ups on the volume's VM; the others are calculations and simulations with AWS list prices for us-east-1 in October 2026: Lambda (arm64) $0.0000133334 per GB-second plus $0.20 per million requests; Fargate (arm64) $0.03238 per vCPU-hour and $0.00356 per GB-hour; m7g.large on-demand $0.0816 per hour. Check current prices before reusing the numbers.

Experiment 1: what a cold start is made of

Ten starts each, measured to the first answered request or the framework's "Started" log line:

Text
Go static binary (tiffin):                median 4 ms
Python process + import boto3 + client:   median 320 ms (216 ms of it the SDK import and client)
Spring Boot 4.1 minimal web app, JDK 21:  2.3–2.6 s to "Started", 2.6–2.9 s of process time
warm Python invocation:                   1.6 µs

Runtime and framework choice dominate start-up: three orders of magnitude between a static Go binary and a JVM framework. For functions and scale-to-zero containers, budget for it (or remove it with SnapStart, native images or minimum instances); for long-running services, it only affects deploys and scale-out speed. Measure your own: the cheapest optimisation is usually removing imports and work done at start-up that no request needs.

Experiment 2: the same API on three kinds of compute

A service doing 120 ms of work per request in 512 MB, priced per month for three traffic shapes. Fargate tasks (1 vCPU, 2 GB, 150 req/s each) scale hourly with at least 2; EC2 is at least two m7g.large sized for the peak and always on:

Text
steady 300 req/s                           (778 M req/month): Lambda $778 | Fargate scaled hourly $57 | 2+ EC2 sized for peak $118
spiky: 5 req/s, 1,500 req/s for 2 h a day  (336 M req/month): Lambda $336 | Fargate scaled hourly $76 | 2+ EC2 sized for peak $294
tiny: 2 req/s                              (5 M req/month):   Lambda $5   | Fargate scaled hourly $57 | 2+ EC2 sized for peak $118
concurrency needed (Little's law) at 1,500 req/s × 120 ms: 180 concurrent function instances

Functions were by far the cheapest for the tiny workload and the most expensive for steady traffic, because you pay per request for work a container could do at a flat rate. Peak-sized VMs wasted most of their hours on the spiky workload. The numbers ignore things that often matter more: engineering time to operate each option, load balancers and NAT, savings plans (up to roughly 50–70% off steady compute), and how latency-sensitive the cold starts are. Little's law also sets the function concurrency you must have quota for: 180 concurrent environments at the peak (the default Lambda account limit is 1,000 per region).

Experiment 3: scaling that reacts versus scaling that's scheduled

Lunch traffic ramps from 300 to 2,700 req/s in 30 minutes; instances handle 200 req/s; reactive target tracking aims for 60% utilisation, and new instances serve only after their warm-up:

Text
instance warm-up 2 min: reactive overloaded for 0 min; scheduled scale-up to 14 at 11:50 overloaded for 0 min
instance warm-up 5 min: reactive overloaded for 3 min; scheduled scale-up to 14 at 11:50 overloaded for 0 min

Reactive scaling worked while instances were ready quickly relative to the ramp; with a 5-minute boot-and-warm-up (realistic for a JVM service on a fresh VM with a large image), demand outran capacity for three minutes despite the 40% headroom. For predictable peaks, schedule or use predictive scaling; for the rest, shorten warm-up (pre-baked images, warm pools, smaller start-up work) and keep enough headroom to cover warm-up time × ramp rate.

Experiment 4: spot interruptions and checkpoints

A 120-minute batch job on spot capacity that is reclaimed every 45 minutes on average; getting a replacement takes 3 minutes; a checkpoint costs 30 seconds:

Text
no checkpoints:           median 466 min, p95 1,669 min
checkpoint every 10 min:  median 145 min, p95 175 min

Without checkpoints, most attempts were interrupted before finishing and started over: three times longer in the median and nearly 14× worse at the tail, eating the spot discount. Checkpointing made the job predictable. Spot suits interruptible work that can resume (batch, CI, rendering, stateless web tiers behind a load balancer); handle the two-minute interruption notice, diversify across instance types and zones (capacity-optimised allocation), and keep a baseline of on-demand capacity for anything user-facing.

Try it yourself

  1. Measure the same Python cold start with the import moved inside the handler. What changes for cold and warm calls?
  2. Build the Spring Boot app as a GraalVM native image (or use JDK 25's AOT cache) and measure start-up again.
  3. Re-run experiment 2 with a 1-year Compute Savings Plan discount on Fargate and EC2.
  4. In a real account, deploy one function with and without provisioned concurrency and measure p99 latency after 30 minutes idle.

Revision sheet: compute

Key ideas

  • Spectrum: VMs → managed Kubernetes → serverless containers → functions → application platforms; control vs operations vs scaling speed.
  • VMs: instance families (general, compute, memory, storage, accelerated), sizes, architectures (x86, Arm/Graviton/Cobalt/Axion), images (AMIs), user data, metadata service (IMDSv2), placement groups, burstable instances.
  • Autoscaling groups: launch templates, health checks, target tracking, step and scheduled scaling, predictive scaling, warm pools, instance refresh, mixed instances and spot.
  • Containers in the cloud: ECS, EKS, AKS, GKE (Autopilot, Auto Mode), Fargate, Cloud Run, Container Apps.
  • Functions: event sources, execution environments, cold starts, concurrency and limits, provisioned concurrency, SnapStart, timeouts, idempotent handlers.
  • Batch and HPC: AWS Batch, spot fleets, GPUs, job checkpointing.
  • Pricing: on-demand, savings plans/reserved/committed use, spot/preemptible, per-second billing, Arm price-performance.

Numbers to remember

  • Spot interruption notice: 2 minutes (AWS); Lambda default concurrency limit 1,000 per region; Lambda max timeout 15 minutes.
  • Lab: cold starts 4 ms (Go), 320 ms (Python + SDK), ~2.5 s (Spring Boot); Lambda cost 14× Fargate at steady 300 req/s but 11× cheaper at 2 req/s; 5-minute warm-up caused 3 minutes of overload; checkpoints cut a spot job's p95 from 1,669 to 175 min.

Pitfalls

  • Heavy initialisation in function handlers.
  • Long-running or steady high-throughput work on functions without doing the maths.
  • Reactive autoscaling with slow warm-up and no headroom.
  • Spot for non-interruptible work, or a single spot instance type.
  • IMDSv1 left enabled.
  • Oversized instances never rightsized.

Glossary

  • Cold start: initialising a new execution environment.
  • Provisioned concurrency / minimum instances: pre-initialised capacity.
  • Launch template: definition of how to launch instances.
  • Target tracking: scaling to keep a metric near a target.
  • Warm pool: pre-initialised stopped instances for faster scale-out.
  • Savings plan: commitment to spend per hour in exchange for discounts.