Horizontal Pod Autoscaler (HPA) adds replicas when CPU/memory/custom metrics exceed thresholds. Scale-to-zero (Knative, serverless) eliminates idle costs but adds cold start latency. The right strategy depends on traffic patterns — bursty vs steady, latency-tolerant vs strict SLO.
1,200 requests a second at 80 ms each means 96 in flight (Little’s law). With 8 concurrent requests per replica and a 70% utilisation target, that needs 18 replicas. Kubernetes’ own rule gets there step by step: 10 replicas at 92% CPU against a 70% target become 14 on the next evaluation.
- Scaling reacts after load arrives; with cold starts of tens of seconds, a spike is served by the replicas you already had.
- CPU is a poor signal for GPU or I/O-bound models; scale on queue length or concurrency.
- Scale-to-zero saves money at the price of a slow first request; not every endpoint can afford it.
import math rps, latency_s, per_replica = 1_200, 0.080, 8 # traffic, time per request, concurrent requests per replica in_flight = rps * latency_s # Little's law replicas = math.ceil(in_flight / (per_replica * 0.70)) # target 70% utilisation current, cpu, target = 10, 0.92, 0.70 hpa = math.ceil(current * cpu / target) # Kubernetes HPA rule
Assumes import numpy as np and import pandas as pd. Each snippet carries its own example numbers; the comments say which are made up or simulated.
- Kubernetes documentation, “Horizontal Pod Autoscaling”, kubernetes.io — the replica formula
- J. D. C. Little, “A Proof for the Queuing Formula: L = λW”, Operations Research 9(3), 1961
- Site Reliability Engineering: How Google Runs Production Systems, B. Beyer, C. Jones, J. Petoff & N. R. Murphy (eds.), O’Reilly, 2016
Last reviewed October 2026 · How this site checks its content · Report a mistake