Free — no signup required

Bin-Packing: The Game of Tetris

1 min read

The Waste Problem

Bin-packing is the art of fitting items into containers with minimum wasted space. In Kubernetes, the "items" are pods (with their CPU and memory requests) and the "containers" are nodes (EC2 instances with fixed capacity).

Poor bin-packing is the single largest source of unnecessary cloud spend in Kubernetes clusters. Here is a concrete example:

Scenario: 4 pods arrive simultaneously, each requesting 0.5 vCPU and 512Mi memory.

Autoscaler Decision Result
CAS (ASG: m5.large, 2 vCPU / 8Gi) Launches 1 m5.large per pod (worst case, if ASG has no pending awareness) 4 nodes × 1.5 wasted vCPU = 6 vCPUs wasted
Karpenter Sees all 4 pods together. Total need: 2 vCPU, 2Gi. Launches 1 m5.large. 0 vCPUs wasted

Karpenter's batching window is key here: it deliberately waits a short period (default 1 second) before provisioning so it can see all pending pods at once and make a single, optimal decision. CAS, by contrast, may react to each pod individually.

In practice, Karpenter's bin-packing can reduce compute costs by 20–40% compared to CAS on the same workload, simply by choosing smaller, better-fitting instances.

This is one of 18 chapters

Get every chapter — Kubernetes, Terraform, SRE, distributed systems, and more — with fast daily review built in.

See pricing