Level 0: Foundation
★☆☆☆☆ Introductory⏱ 5 minGeneral audience. No mathematics required.Shipping containers for software
Before standard shipping containers, every cargo was loaded differently; afterwards, any crane, ship or truck could move any box. Software containers do the same: the model, its code and every library go into one image that any machine can run. Kubernetes is the port authority: it decides which machine runs which container, replaces broken ones, swaps in new versions without stopping the service, and adds or removes copies as traffic rises and falls. The catch is that new copies of a large model take minutes to start, and traffic does not wait.
Bar length: pod-hours for one day; colour: share of the 2× spike at 10:30 above ready capacity (green none, amber some, red over 5%).
N3-2, seed 0: 2,045 requests per second on average, pods of 100 per second. Slow-starting pods (large images, model loading) turn a sudden spike into lost requests unless the target leaves headroom or the service scales up before a known event.
In Exercise 2, autoscaling cost 62% of provisioning for the peak, but when pods took 10 minutes to start, 9 to 15% of a sudden spike went unserved at 70 to 90% targets; scaling up ahead of the known event removed the shortfall for 6 extra pod-hours.
- 1. A container image contains…
- 2. Kubernetes places pods on nodes based on…
- 3. Autoscaling adds pods when…
Level 1: Beginner
★★☆☆☆ Basic⏱ 20 minSecondary-school mathematics: arithmetic and elementary algebra.By hand
- Image and container: an image is a stack of read-only layers (base system, libraries, code); a container is a running instance with its own filesystem and process space.
- Pod: the smallest unit Kubernetes schedules: one or more containers sharing network and storage.
- Requests and limits: CPU and memory a pod reserves (used for scheduling) and may not exceed (memory over the limit is killed: OOM).
- Scheduler: filters nodes with room for a pod, then scores them; LeastAllocated spreads pods, MostAllocated packs them.
- Deployment and rolling update: keeps n replicas; maxSurge and maxUnavailable bound extra and missing pods during an update.
- Probes: liveness restarts stuck containers; readiness keeps traffic away until the pod can serve.
- Horizontal Pod Autoscaler: desired = ceil(current × metric / target), with a tolerance and a scale-down stabilization window.
- Cluster autoscaler: adds nodes when pods are pending and removes empty ones.
- 1. A pod's memory limit, when exceeded, leads to…
- 2. A readiness probe…
- 3. The MostAllocated score…
Level 2: Intermediate
★★★☆☆ Intermediate⏱ 25 minUndergraduate students and practising engineers.A scheduler and an autoscaler
Exercise 1.
- Scheduler: filter nodes with enough free CPU and memory, score by mean allocation after placement (spread or pack).
- HPA: desired = ceil(current × utilization / target), unchanged within 10%; scale-down uses the highest desired count of the last 5 minutes; new pods serve after a start-up delay.
- Traffic: one day every 15 s, mean about 2,000 requests per second with a daily cycle (lowest at 4:00), 5% noise and a spike to 2× at 10:30 for 30 minutes, ramping up in 2 minutes.
- Each pod serves 100 requests per second within the latency target (topic N3-1).
Practice.
- Build small, layered images: stable layers first, code last; keep large weights in their own layer or volume.
- Set requests from measured use and memory limits with a margin for growth.
- Use readiness probes for anything that loads a model.
- Leave autoscaling headroom that covers the spike growth during one pod start-up.
- Scale ahead of known events and keep spare nodes when node provisioning is slow.
def hpa_desired(current, utilization, target, tolerance=0.1):
ratio = utilization / target
if abs(ratio - 1) <= tolerance:
return current
return int(np.ceil(current * ratio))
# every 15 s: read utilization of ready pods, compute desired,
# scale down only to the highest desired count of the last 5 minutes,
# new pods serve after their start-up time- 1. A high HPA target utilization…
- 2. Slow pod start-up mostly hurts…
- 3. Putting the code layer last in an image…
Level 3: Advanced
★★★★☆ Advanced⏱ 25 minGraduate level, with full derivations and proofs.Theory
Autoscaling as feedback. The HPA is a proportional controller acting every 15 s on a delayed system: pods it orders serve only after their start-up time τ. If load grows at relative rate g, capacity ordered now is behind by about a factor e^(gτ) when it arrives. A target utilization u leaves headroom 1/u: the service keeps up as long as load does not grow by more than 1/u during τ. With u = 0.7 the headroom is 43%; a spike that doubles the load in 2 minutes exceeds it, and the shortfall lasts about τ.
Cost. Over a day, autoscaling costs roughly mean load / (u × pod capacity) pod-hours plus the lag of scale-down, while fixed provisioning costs peak load / capacity for every hour. With a peak 2.5 times the mean, the HPA at u = 0.7 used 62% of the peak provisioning’s pod-hours.
Bin packing. Placing pods on the fewest nodes is a vector bin-packing problem (NP-hard); schedulers use greedy scores. Spreading balances load and failure risk but fragments free capacity, so a large pod may find no node; packing keeps whole nodes free.
Layers. Image layers are addressed by content, as pipeline steps were in topic N2-3: a layer is rebuilt when it or anything below it changes, so the order of layers decides what each deploy must pull.
- 1. With target utilization u, the headroom against a load increase is…
- 2. A shortfall after a sudden spike lasts about…
- 3. Spreading pods across nodes tends to…
Level 4: Expert
★★★★★ Expert⏱ 30 minResearchers: original papers and open problems.How should a model service scale through a day with a sudden spike, given that new pods take time to start?
History.
- Unix chroot (1979), FreeBSD jails (2000) and Linux control groups (Google, 2006–2008) provided isolation; Docker (S. Hykes, 2013) made layered images and containers easy to build and share.
- Google’s Borg (A. Verma and colleagues, 2015, in use since about 2004) scheduled containers across clusters; Kubernetes, released by Google in 2014 and donated to the CNCF in 2015, brought those ideas into the open.
- The Horizontal Pod Autoscaler appeared in Kubernetes 1.1 (2015); KServe, Seldon and Kubeflow later added model serving and pipelines on top.
Exercise 2.
- Fixed pods for the peak or for the mean; the HPA with targets 0.5, 0.7 and 0.9; and the HPA at 0.7 with a scheduled minimum from 10 minutes before the spike until it ends, for pod start-up times of 30 s, 3 minutes and 10 minutes.
- Unserved share: requests above the capacity of ready pods, for the whole day and for the 30-minute spike.
Seed 0 (mean 2,045, peak 5,104 requests per second):
| policy | start-up | pod-hours | day unserved | spike unserved |
|---|---|---|---|---|
| fixed for the peak (52 pods) | – | 1,248 | 0 | 0 |
| fixed for the mean (21 pods) | – | 504 | 18.6% | 52.2% |
| HPA 0.5 | 30 s / 3 min / 10 min | 1,075 / 1,076 / 1,067 | 0 / 0 / 0.04% | 0 / 0 / 0.8% |
| HPA 0.7 | 30 s / 3 min / 10 min | 774 / 773 / 765 | 0 / 0.06% / 0.39% | 0 / 1.3% / 8.7% |
| HPA 0.9 | 30 s / 3 min / 10 min | 602 / 601 / 601 | 0.01% / 0.18% / 0.67% | 0.3% / 3.9% / 14.5% |
| HPA 0.7 + scheduled | 30 s / 3 min / 10 min | 781 / 780 / 771 | 0 | 0 |
Seeds 1 and 2: HPA 0.7 used 63% of peak provisioning (770 and 771 against 1,224 pod-hours); with 10-minute starts it left 9.2% and 8.8% of the spike unserved, HPA 0.9 15.1% and 14.5%; the scheduled minimum removed every shortfall for 5 to 7 extra pod-hours in every seed.
Findings.
- Autoscaling at a 70% target cost 62 to 63% of provisioning for the peak in every seed, and served everything when pods started in 30 s.
- Slow starts turned the spike into lost requests: with 10-minute starts, 9 to 15% of the spike went unserved at 70 to 90% targets; only a 50% target, at 40% more pod-hours, nearly avoided it.
- Scaling up before a known event removed the shortfall at every start-up time for 5 to 7 extra pod-hours; unknown spikes need faster starts or headroom.
Containers and Kubernetes in practice
- Model images are large (CUDA, frameworks, weights); teams cut start-up with slim base images, weights on shared volumes or object storage with local caches, and image pre-pulling on nodes.
- GPU scheduling uses device plugins and node pools; GPUs are expensive, so packing and autoscaling to zero for idle models matter.
- Event-driven autoscalers (KEDA, Knative) scale on queue length or request rate rather than CPU, and can scale to zero.
- Ground systems for space missions run processing pipelines in containers so the exact environment used for a data product can be rerun years later.
References
- D. Merkel (2014). “Docker: lightweight Linux containers for consistent development and deployment.” Linux Journal.
- A. Verma, L. Pedrosa, M. Korupolu, D. Oppenheimer, E. Tune and J. Wilkes (2015). “Large-scale cluster management at Google with Borg.” EuroSys.
- B. Burns, B. Grant, D. Oppenheimer, E. Brewer and J. Wilkes (2016). “Borg, Omega, and Kubernetes.” ACM Queue.
- Kubernetes documentation (2015–). “Horizontal Pod Autoscaling” and “Scheduling Framework.” kubernetes.io.
- M. Mao and M. Humphrey (2012). “A performance study on the VM startup time in the cloud.” IEEE CLOUD.