interviewpath
  • 0day streak
  • 10total XP
  • Level 1
0/6

Unit 13 · Cloud research · Lesson 3 of 5

Elasticity, autoscaling and serverless cold starts

Elastic systems add and remove capacity as load changes; the hard parts are reacting fast enough without oscillating and trading idle capacity against cold-start latency. Serverless platforms make that trade-off explicit with keep-alive and pre-warming policies, and microVMs such as Firecracker make fast, isolated startup possible.
About 3 h 30 minFocus mode

Step 1: Learn the ideas

  • Horizontal versus vertical scaling; reactive versus predictive scaling
  • HPA: metrics, proportional target tracking, tolerance, stabilization windows, scaling policies
  • Cluster autoscaling and node provisioning delay
  • Cold-start anatomy: sandbox, runtime, code or model loading, initialization
  • Keep-alive, pre-warming and pools sized with Little’s law
  • Serverless workload characteristics: skewed invocation rates, short executions
  • Sandboxes: containers, microVMs (Firecracker), snapshot and restore
  • Scale-to-zero and its latency cost
  • Geographic deployment, data locality and cost (awareness)

Why it matters

Elastic systems add and remove capacity as load changes. The hard parts are reacting quickly without oscillating, and choosing between paying for idle capacity and paying cold-start latency. Serverless platforms make that trade-off explicit through keep-alive and pre-warming policies, and microVMs such as Firecracker make fast, isolated startup possible. Research and infrastructure interviews ask you to reason about both the control loop and the cost of starting things.

Core ideas

Elasticity is a control loop with delays. Observe a metric, decide a target, act, wait for the effect. Each stage adds delay: metric collection and averaging, the controller's period, scheduling the new instance, provisioning a node when none has room (usually much slower than starting a pod on an existing node), pulling images, booting the sandbox, starting the runtime and initializing the application. Load that rises faster than this chain reacts lands in queues, so headroom, limits and load shedding remain necessary.

Kubernetes HPA. The controller periodically computes desired replicas = ceil(current replicas × current metric / target metric), skips changes within a tolerance band, treats unready pods and missing metrics conservatively, and smooths scale-down with a stabilization window; scaling policies bound how fast replicas change. CPU utilization is convenient but indirect; request rate, concurrency or queue length per replica track load more directly for latency-critical services (queue depth or KV-cache usage for LLM serving).

Oscillation. Aggressive scale-down with slow scale-up makes replicas flap. Asymmetric policies, stabilization windows and predictive scaling for known daily patterns reduce it.

Cold starts. A cold start pays for placement, sandbox creation, runtime start, code or model download and initialization code. Platforms shorten the sandbox part with lightweight VMMs, keep pools of pre-booted sandboxes (the Firecracker paper sizes such a pool with Little's law: pool size ≈ creation rate × creation latency) and restore from snapshots. Applications shorten their part by trimming dependencies and deferring work; for ML inference, loading weights can dominate.

Keep-alive and pre-warming. Keeping an instance warm after an invocation avoids the next cold start but holds memory. Shahrad et al. found in the Azure Functions workload that invocation rates span many orders of magnitude and that most applications are invoked rarely, so one fixed window fits badly: it wastes memory on rare applications and still misses their next call. Their hybrid histogram policy tracks each application's idle-time distribution and chooses a pre-warm delay and keep-alive window from its head and tail, falling back to a fixed window when data are scarce and to time-series forecasting when idle times exceed the histogram range. They evaluate cold-start percentage against wasted memory time.

Isolation and density. One microVM per function gives VM-level isolation; Firecracker argues that a minimal VMM keeps memory overhead and boot time low enough for this, and that soft allocation (oversubscription) makes idle instances cheap.

Geography and cost (awareness). Spreading capacity across regions lowers user latency and isolates failures but fragments pools (less statistical multiplexing), complicates data locality and changes prices, so autoscaling interacts with where users and data are.

Common misconceptions

  • "Autoscaling removes the need for capacity planning." Reaction delays mean bursts hit queues first; headroom and limits are still required.
  • "Cold starts are just image pulls." Sandbox boot, runtime start and application initialization often dominate, and weight loading dominates for ML services.
  • "A longer keep-alive is a cheap fix." It helps frequently invoked applications and wastes memory on rare ones; per-application policies reach a better trade-off curve.
  • "Scale to zero is free." It removes idle cost but guarantees cold starts after idle periods.
  • "VMs are too slow for serverless." A specialized VMM combined with pools starts fast enough, at the cost of a deliberately limited device model.

How to approach it

Run the HPA walkthrough with a load step and timestamp each stage of scale-up. Simulate keep-alive policies on the Azure Functions trace and plot cold starts against idle memory. In interviews, decompose latency into the stages above and say which ones a proposed change shortens.

Suggested order

  1. 1Read the Kubernetes Horizontal Pod Autoscaling page (algorithm details, stabilization, scaling policies) and run the HPA walkthrough.
  2. 2Read the AWS Lambda execution environment lifecycle page and list the phases of a cold start.
  3. 3Read Serverless in the Wild: the workload characterization, then the hybrid histogram policy and its evaluation.
  4. 4Read Firecracker sections 4.1 and 4.2 on Lambda’s architecture, slots, pre-booted pools and soft allocation.
  5. 5Do the keep-alive simulation project on the Azure Functions trace; optionally run the HPA experiment.

Paper guides: Firecracker: Lightweight Virtualization for Serverless Applications, Serverless in the Wild: Characterizing and Optimizing the Serverless Workload at a Large Cloud Provider

Step 2: Check off what you can do

Tap each one you can genuinely do or explain. Each earns 10 XP.

Step 3: Go deeper

  • Serverless in the Wild: Characterizing and Optimizing the Serverless Workload at a Large Cloud ProviderStart here

    USENIX

    Production FaaS workload characteristics and the cold-start versus memory trade-off of keep-alive policies.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Firecracker: Lightweight Virtualization for Serverless ApplicationsStart here

    USENIX

    Section: Section 4: Firecracker In Production

    How Lambda uses microVM slots, pre-booted pools sized with Little’s law, and soft allocation.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Kubernetes: Horizontal Pod Autoscaling

    Kubernetes project

    The autoscaling control loop, its formula and its anti-oscillation mechanisms.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • AWS Lambda: Understanding the Lambda execution environment lifecycle

    Amazon Web Services

    A production description of execution-environment phases and cold starts.

    Open(opens in a new tab)Link responded, 5 Oct 2026
  • Azure Public Dataset

    Microsoft Azure and Microsoft Research (GitHub)

    Section: Azure Functions trace 2019

    The invocation trace for replaying keep-alive and pre-warming policies.

    Open(opens in a new tab)Link responded, 5 Oct 2026

Step 4: Practice

Start with the keep-alive simulation: sample a few thousand applications from the 2019 Functions trace, simulate fixed windows of several lengths and a simple per-application histogram policy, and plot cold-start percentage against wasted memory time. Then, on a local cluster, apply a load step to an autoscaled service and timestamp each scale-up stage. If you have a KVM-capable Linux host, measure microVM boot times with a written method. Report what you measured; do not borrow figures from the papers.

Record attempts on each problem’s page (+15 XP, +10 more when solved on your own).

Step 5: Test yourself

Answer each one out loud or on paper before you finish the lesson.

  1. Question 1Why does a reactive autoscaler still need headroom?
  2. Question 2What does the HPA stabilization window prevent?
  3. Question 3Why is a single fixed keep-alive window a poor fit for a skewed workload?
  4. Question 4How does Little’s law size a pool of pre-booted sandboxes?
  5. Question 5What does scale-to-zero cost in latency, and when is that acceptable?

You’re done when you can

  • Decompose scale-up latency into stages and say which stages a pre-warmed pool removes.
  • Apply the HPA formula to an example and explain tolerance and stabilization.
  • Evaluate at least two keep-alive policies on a trace sample by cold-start rate and wasted memory time.
  • Explain how Firecracker’s design supports per-function isolation at serverless density.

Finish the lesson

How confident do you feel?

Lesson complete!

+50 XP

Reviews will come up on the Practice tab so it sticks.

Your notes and study time

Log study time