Bin Packer: Requests & Limits

Pods book CPU and memory; the scheduler places them by what they booked. Then real usage decides who gets slowed, killed or evicted.

Back to Labs
New to Kubernetes? Read this first

Think of booking seats on a train. The ticket office (the scheduler) only counts seats booked, not who actually turns up or how much luggage they bring. Here, a pod books CPU and memory; what it really uses can be smaller or bigger.

Node
A machine with a fixed amount of CPU and memory. Each node here has 2000m CPU (two cores) and 2048Mi memory.
Pod
A running app. The scheduler places each pod on one node.
Request
What a pod books. The scheduler adds up bookings and only places a pod where its booking still fits. Nothing is set aside on the machine: a pod can use less than it booked, or more.
Limit
A hard cap on what the pod may use. Over its CPU cap it is slowed down. Over its memory cap it is killed and restarted.
Usage
What the pod actually uses right now.
Load
Multiplies every pod’s usage. Requests and limits stay the same.

Units: CPU is in millicores, 1000m is one core. Memory is in mebibytes, 1024Mi is 1Gi. The requests and limits post walks through this lab step by step.

Start here: move Load to 1.25x and watch node-b. Every pod fit by its requests, but actual usage didn’t, so node-b evicts cache-2. Then try 1.75x (CPU throttling) and 2x (memory OOM kills).

1x

Load multiplies what every pod actually uses. Requests and limits stay the same.

  • Booked (requests): What the scheduler counts when it places pods.
  • Actually using: What the pods really use at this load.
  • Memory-pressure line: If memory in use goes past it, the node evicts pods until it is back under.
CPU booked (requests) 600m30%
CPU actually using 1000m50%
Memory booked (requests) 384Mi19%
Memory actually using 650Mi32%

Memory-pressure line at 1792Mi

CPU booked (requests) 550m28%
CPU actually using 600m30%
Memory booked (requests) 512Mi25%
Memory actually using 1630Mi80%

Memory-pressure line at 1792Mi

CPU booked (requests) 750m38%
CPU actually using 1200m60%
Memory booked (requests) 384Mi19%
Memory actually using 480Mi23%

Memory-pressure line at 1792Mi

Not scheduled (0)

Every pod fits somewhere. Queue a pod with a big request to see Pending.

Pod states

QoS class (eviction order)

QoS changes the eviction order. It does not make any pod immune.

Custom pod

Burstable
250m
500m
256Mi

Demand at 1x load (what the app actually wants, independent of requests)

200m
300Mi

Effective requests: 250m, 256Mi

What this hides

One container per pod, restartPolicy: Always, owned by a Deployment, all at equal priority. This is a snapshot, not a timeline.

OOM is instant here. The real kernel kills the container after memory goes over its limit, and the kubelet restarts it.

Eviction follows the kubelet's order: pods using more than their memory request first, then the largest overage above request. It is not sorted by QoS class directly.

Here a replacement only shows up once the load drops back. In a real cluster the Deployment creates it straight away, and the scheduler places it like any new pod, maybe on another node.

Not modelled: allocatable vs capacity, CPU shares under contention, priority and preemption, taints and affinity.