Unit 6 of 12 · about 4 hours · derive
Autoscaling signals, startup lag, failure reserve and degraded-mode headroom
Replicas arrive minutes after the spike that needs them. Capacity math done before the incident is the only autoscaling that works on GPU cold starts.
You'll be able to
- Derive desired replicas from queue depth, latency ratio and Little's law for one declared workload.
- Size warm pools and failure reserve from startup lag and replica availability math.
- Explain why CPU-based autoscaling misfires on LLM serving and which signals replace it.
Covers
Read
In this order, only the parts listed
0 of 5 done
- Autoscaling and warm poolsMachine Learning Systems, Volume 2 - Inference at Scale and Serving Fault Tolerance
Autoscaling and Global Infrastructure, Scaling dimensions through Scaling response time analysis: Table 38 scaling dimensions, reactive Listing 3 with the queue-depth and P99-ratio desired-replica rules, predictive Listings 4 and 5 with
Target = max(Predicted, Reactive) + Buffer, Table 43 warm tiers, equation 15 with Table 44 (page read 2026-10-14) - Availability with redundant replicasMachine Learning Systems, Volume 2 - Inference at Scale and Serving Fault Tolerance
Serving Fault Tolerance, Redundancy and replication, Availability calculations: equation 11 with the 99% to 99.99% worked example and its independence assumption (page read 2026-10-14)
- Autoscaling signals and scale-to-zeroInference Engineering - Chapter 7, Production
Section 7.2 (printed pp. 183-186): utilization versus traffic signals and the five autoscaling factors; Section 7.2.1 (printed pp. 186-188): concurrency target matched to batch size; Section 7.2.4 (printed p. 192): scale-to-zero prerequisites; Section 7.2.5 (printed p. 192): per-component scaling with the 10ms in-cluster versus 50ms cross-cluster example
- Day 23 autoscaling simulator100 Days of LLM Inference - Days 22 to 26
Part 1
simulate_autoscalingwithmin_replicas=2,max_replicas=20,concurrency_target=5,scale_down_delay_sec=300; the throughput model flattening near batch 299; Try These Experiments 1, 2, 4 and 5 (delay sweep, concurrency sweep, predictive pre-warm, cheapestmin_replicas)The README (~90 concurrent) and the notebook cell (230) disagree on Llama-3-8B H100 capacity at 2048 context. Recompute KV bytes per token for your own model and context instead of quoting either number.
- Project 103 HPA and scaling guidanceAI Infrastructure Engineer Learning - Project 103 LLM Deployment
hpa.yaml:minReplicas: 1,maxReplicas: 3, CPU 70% and memory 80% signals, scale-down stabilization 300s, commented per-second custom metric;docs/TROUBLESHOOTING.mdsection 9: replacing CPU withvllm:num_requests_waitingthrough the Prometheus adapter or KEDA
Focus on
- Three replica rules must agree: Little's law for the workload, queue-depth for the backlog, and the P99-ratio rule for SLO defense. When they disagree, the pool is either cold or saturated.
- Response time is , and provisioning dominates by an order of magnitude. Warm pools buy down the dominant term; faster metrics never will.
- CPU at 70% is the wrong signal for decode-bound serving: a few long prompts fill the KV cache and the GPU while host CPUs idle. Scale on
vllm:num_requests_waiting, queue depth and TTFT, not on CPU. - Availability assumes independent failures. Shared power, networking or a fleet-wide bad config removes the exponent, so failure reserve also needs failure diversity.
Common mistakes · 3
- Shipping the Project 103 default HPA unchanged. CPU and memory signals miss GPU-bound decode pressure; add the waiting-requests custom metric before trusting it.
- Setting a short scale-down delay to save money. It oscillates: replicas leave, the queue rebuilds, cold replicas return. The 300s stabilization window exists for this cycle.
- Putting SLO-critical traffic on spot. Thirty seconds to two minutes of termination notice cannot drain long decodes; keep spot to best-effort classes behind the same drain path.
Try it yourself
Closed-book, before checking anything
Quiz yourself
Answer first, then mark it. Missed ones go to Review.
0 got · 0 missed
1.Arrivals run 10 requests/s with 3s service time and 5 concurrency per replica. How many replicas at the 80% rule?Answer
In flight , which needs 6 replicas at full load and under the 80% headroom rule.
2.Latency is fine at 70% utilization but p99 explodes at 95%. Why is the ratio not 95/70?Answer
Queueing delay grows like , not in proportion to . In an M/M/1 model, mean and p99 response time both rise about sixfold from to (), and burstier real arrivals make the tail worse. Size to 70 to 80% utilization.
3.One replica is 99% available (3.65 days down per year). What do two give, and when does the math lie?Answer
%, about 52.6 minutes per year. It lies when failures correlate: shared power, network, zone or a bad fleet-wide rollout fails both together.
4.Traffic is flat but TTFT climbs steadily. Which autoscaling signal fires, and what does it mean?Answer
The P99-ratio and waiting-requests signals fire while CPU stays flat. It means per-request work grew (longer prompts, colder cache), not request count; add replicas or shed by work, not by rate.
Practice
- 100 Days day23: autoscaling sweeps
Try These Experiments 1 (sweep
scale_down_delay_secover 60 to 900 keeping violations under 5%), 2 (sweepconcurrency_target2 to 20 on p50/p99), 4 (predictive 15-minute pre-warm versus reactive) and 5 (cheapestmin_replicaswith p99 cold start under 1s)Run the sweeps in the notebook, then recompute the concurrency bound from your own model's KV bytes per token instead of the notebook's 230.
You're done when
Your three replica rules agree on one declared workload, and you can price the warm pool that covers one startup lag.
Only when you can do this without notes.
Leads to
Notes
Resources · 4 for this unit, 9 more in the section
- Machine Learning Systems, Volume 2 - Inference at Scale and Serving Fault ToleranceHarvard (Vijay Janapa Reddi) · required
Read "Load Balancing and Request Routing", "Multi-Tenancy and Isolation" and "Autoscaling and Global Infrastructure" in Inference at Scale, then "Serving Fault Tolerance" and "Graceful Degradation" in the Fault Tolerance chapter.
- Inference Engineering - Chapter 7, ProductionPhilip Kiely (Baseten Books) · support
Read Chapter 7 for containers, autoscaling, cold starts, routing and queueing, zero-downtime deployment, cost estimation and client-side streaming. Skip the vendor section at its end.
- 100 Days of LLM Inference - Days 22 to 26Elizabeth Thomas · support
Use the container, autoscaling, routing, capacity and zero-downtime notebooks as small operational simulations. Replace calendar order and fixed scale targets with the stage checkpoint and your hardware limits.
- AI Infrastructure Engineer Learning - Project 103 LLM DeploymentAI Infra Curriculum · support
Use its Docker, API, monitoring, Kubernetes and cost files as scaffolding only. Check its resource assumptions against your own model and GPU, and rerun any benchmark before reusing a result.
Also in this section
- vLLM Online Serving, Architecture and Production MetricsvLLM Project · primary
Trace the API server, engine core, scheduler, KV manager and model runner, then map documented metrics to your SLIs. The link is pinned to v0.31.0; add the auth, tenant, quality and rollout controls the engine leaves to you.
- Hands-On LLM Serving and Optimization - Chapters 3 and 4, serving system designChi Wang and Peiheng Hu (O'Reilly) · required
Read Chapter 3 (an online service from scratch, batching with streaming, multi-model trade-offs) and the enterprise-architecture part of Chapter 4. Convert the designs into explicit request, model-lifecycle and failure state machines.
- vLLM Production MetricsvLLM Project · required
Define every selected queue, cache, phase and request metric, check histogram buckets and measure exporter overhead. Add model version, cancellation, rejection, quality sample and tenant-safe trace fields in the surrounding service.
- Gateway API Inference ExtensionKubernetes SIG Network · required
Study model-aware routing, endpoint selection and operational integration. Use it for architecture and an optional local deployment only after the service passes lifecycle and failure tests without Kubernetes.
- SGLang documentation - Production MetricsSGLang Project · support
Compare its metric names and phase boundaries with vLLM's, so your dashboards do not depend on one engine's vocabulary.
- AI Systems Performance Engineering - Production Inference LabsChris Fregly · required
Use Chapter 16 monitoring, cache health, capacity planning and load-test utilities, then Chapter 17 routing only if distributed. Add process death, overload and bad-version cases that the performance pairs do not cover.
- LLM Inference Systems Laboratory - Operations and FailureRoadmap-Final · support
Complete production gateway, isolation, telemetry, canary, drain, rollback and fault campaigns. Store first-cause timelines and revise runbooks from observed blind spots.
- OpenAI API Reference - streaming, auth, rate limits and request IDsOpenAI · reference
Read the chat streaming event shape with the
[DONE]terminator, bearer auth, rate-limit headers, andx-request-idwith caller-suppliedX-Client-Request-Id. vLLM is the implementation under test; use this only for the contract it claims compatibility with. - vLLM Multimodal Inputs - media validation, fetch policy and cache identityvLLM Project · reference
Read Online Serving for image, video and audio inputs:
--allowed-media-domains, fetch timeouts,--limit-mm-per-prompt, local-media path restriction, and media UUIDs for cache identity. The link is pinned to v0.31.0.