{"slug": "beyond-cpu-utilization-using-psi-to-diagnose-kubernetes-resource-contention", "title": "Beyond CPU Utilization: Using PSI to Diagnose Kubernetes Resource Contention", "summary": "Linux Pressure Stall Information (PSI) metrics became stable in Kubernetes v1.36, letting operators distinguish CPU contention from mere CPU utilization, according to a Kubernetes blog post by an engineer running latency-sensitive AI inference services. In two runs on a kind cluster worker node restricted to two CPUs, kubectl top reported 2001m of CPU usage in both, but CPU pressure measured 0.33% with one pod running two busy loops versus 99.63% with three pods running six loops competing for the same two CPUs. The kubelet Summary API exposes node, pod and container PSI alongside usage, and the kubelet's /metrics/cadvisor endpoint reports the same signal per container as container_pressure_cpu_waiting_seconds_total.", "body_md": "I work on latency-sensitive AI inference services, where understanding why requests slow down matters. CPU utilization is one of the first things I check when investigating performance issues. But it doesn't tell me whether workloads are waiting for CPU time.\n\nThat distinction made me interested in Linux Pressure Stall Information (PSI). A node can be fully utilized with two tasks running on two CPUs, or with six tasks competing for those same CPUs. CPU utilization looks similar in both cases, but the amount of waiting can be very different.\n\nPSI measures that waiting. Kubernetes exposes PSI through the kubelet, and the\nmetrics are\n[stable from Kubernetes v1.36](https://kubernetes.io/blog/2026/05/12/kubernetes-v1-36-psi-metrics-ga/).\n\nI wanted to see the difference for myself, so I ran the same workload in two\nconfigurations on a Kubernetes node restricted to two CPUs. In both runs,\n`kubectl top` showed the node using 2001m of CPU, meaning both CPUs were fully\nbusy. But CPU pressure was 0.33% in the first run and 99.63% in the second.\n\nCPU PSI measures how much of the time at least one task was ready to run but\nwaiting for CPU. This is reported as `some`. An `avg10` of 25% means that, over\nroughly the last 10 seconds, at least one task was waiting about a quarter of\nthe time.\n\nThe kernel reports `some` as averages over the last 10, 60, and 300 seconds\n(`avg10`, `avg60`, `avg300`). I use `avg10`, because it reacts quickly when the\nworkload changes. PSI also reports `full`, the share of time when all tasks\nwere waiting at once; I don't use it here.\n\nThe kubelet Summary API shows CPU usage and PSI together, for the node and for each pod and container:\n\n```\nkubectl get --raw \"/api/v1/nodes/<node-name>/proxy/stats/summary\" \\\n | jq '{cores: (.node.cpu.usageNanoCores / 1e9), psi: .node.cpu.psi}'\n```\n\nPer-pod values are under `.pods[].cpu.psi`. If you use Prometheus, the\nkubelet's `/metrics/cadvisor` endpoint has the same signal per container, as\n`container_pressure_cpu_waiting_seconds_total`.\n\nFor the test, I used a [kind](https://kind.sigs.k8s.io/) cluster on a machine\nwith four CPUs. I gave the worker node two of them and put the control plane on\nthe other two, so the control plane didn't compete with the test workload. The\nworkload is a small pod that runs busy loops. Each loop keeps one CPU fully\nbusy whenever it gets one. The [appendix](#appendix-reproducing-the-runs) has\nthe full setup.\n\nIn each run, I waited 60 seconds for things to settle, then read the node's CPU pressure 12 times, 10 seconds apart. The numbers below are the average of those 12 readings.\n\n**Run A: one pod, two loops.** Two loops on two CPUs, so each loop has a CPU to\nitself.\n\n``` bash\n$ kubectl top nodes\nNAME CPU(cores) CPU(%) MEMORY(bytes) MEMORY(%)\npsi-demo-control-plane 53m 1% 593Mi 7%\npsi-demo-worker 2001m 50% 166Mi 2%\n```\n\nThe worker is using 2001m, so both of its CPUs are fully busy. CPU pressure was\n**0.33%**. The loops almost never had to wait.\n\n**Run B: three pods, six loops.** Six loops now compete for the same two CPUs.\nOnly two can run at once, so the others have to wait.\n\n``` bash\n$ kubectl top nodes\nNAME CPU(cores) CPU(%) MEMORY(bytes) MEMORY(%)\npsi-demo-control-plane 43m 1% 602Mi 7%\npsi-demo-worker 2001m 50% 183Mi 2%\n```\n\nCPU usage is unchanged at 2001m. But CPU pressure was **99.63%**: almost all\nthe time, some loop was waiting for a CPU.\n\nBoth runs show `CPU(%)` as 50% because Kubernetes counts all four of the\nmachine's CPUs as the node's capacity; it doesn't know about the two-CPU\nrestriction.\n\nLooking at CPU usage for the individual pods showed another part of the problem:\n\n``` bash\n$ kubectl top pods\nNAME CPU(cores) MEMORY(bytes)\nspinners-849c6d64c8-g2s9x 616m 0Mi\nspinners-849c6d64c8-ggtqh 667m 0Mi\nspinners-849c6d64c8-q9bvj 708m 0Mi\n```\n\nIn run A, the one pod used 1991m. In run B, each pod uses only 616m to 708m,\neven though each still runs two busy loops. The lower numbers don't mean the\npods need less CPU. They're sharing two CPUs. Nothing in `kubectl top` shows the\nwaiting, but pod-level PSI does: the three pods' CPU pressure was 69%, 99.73%,\nand 99.79% in the last reading.\n\nI also tested what happens when a workload has a CPU limit and the node has\nspare capacity. For **run C**, I went back to one pod with two loops and set its\nCPU limit to 500m.\n\n``` bash\n$ kubectl top nodes\nNAME CPU(cores) CPU(%) MEMORY(bytes) MEMORY(%)\npsi-demo-control-plane 55m 1% 608Mi 7%\npsi-demo-worker 517m 12% 168Mi 2%\n```\n\nThe worker used about 0.51 of its two CPUs, leaving three quarters idle;\n`kubectl top` shows 12% because Kubernetes counts four CPUs of capacity. Even\nso, the node's `some.avg10` averaged **75.23%**. The 500m limit capped the pod's\nCPU usage even though the worker had spare capacity. The two loops used up\ntheir CPU quota and were throttled. The container's throttling counter shows\nit was throttled in 1905 CFS periods since it started:\n\n```\ncontainer_cpu_cfs_throttled_periods_total{container=\"spin\",...} 1905\n```\n\nThe [PSI documentation](https://kubernetes.io/docs/reference/instrumentation/understand-psi-metrics/)\nuses a CPU-limited pod as its example. Here, the throttling counter points to\nthe pod's limit rather than competition with other workloads, so adding node\ncapacity wouldn't reduce this pressure while the pod's CPU limit stays at 500m.\n\nThe three runs show why I'd look at CPU pressure alongside utilization when investigating a performance problem:\n\nI wouldn't pick a universal PSI threshold. A level that's normal for a batch job could be a problem for a latency-sensitive API, so I'd compare pressure against the workload's own baseline and check whether it rose with latency or queue depth.\n\nFor the inference services I work on, latency can increase for different reasons: more processing within the service, waiting for CPU, or a slow call to another service.\n\nThese experiments helped me understand what PSI adds. If I saw latency increasing without a clear explanation from CPU utilization, I'd check pod-level CPU pressure to see whether contention or throttling might be contributing. I'd compare that with application metrics and traces before drawing a conclusion.\n\nI ran this on kind v0.33.0 with Kubernetes v1.36.1, the release in which PSI metrics became stable.\n\n**Requirements:** a Linux host with cgroup v2, a kernel with PSI enabled,\nDocker, kind, kubectl, and jq, with at least 4 CPUs. Check cgroup v2 and PSI on\nthe host:\n\n```\nstat -fc %T /sys/fs/cgroup # expect: cgroup2fs\ncat /proc/pressure/cpu # expect: some and full lines\n```\n\nOn macOS, I used [Colima](https://github.com/abiosoft/colima), an open source\ntool that runs Docker Engine in a Linux VM (installable with Homebrew):\n`colima start --profile psi-demo --runtime docker --cpu 4 --memory 8`, then run\nthe two checks inside the VM with `colima ssh --profile psi-demo -- <command>`.\n\n**Create a two-node cluster** with this `kind-config.yaml`:\n\n```\nkind: Cluster\napiVersion: kind.x-k8s.io/v1alpha4\nnodes:\n- role: control-plane\n- role: worker\nkind create cluster --name psi-demo --image kindest/node:v1.36.1 \\\n --config kind-config.yaml --wait 180s\n```\n\n**Pin the nodes to separate CPUs.** Each kind node is a Docker container, so\nDocker can restrict which CPUs it runs on:\n\n```\ndocker update --cpuset-cpus=\"0,1\" psi-demo-control-plane\ndocker update --cpuset-cpus=\"2,3\" psi-demo-worker\ndocker exec psi-demo-worker nproc # expect: 2\n```\n\nBecause the kind worker is a container, its node-level PSI comes from that\ncontainer's cgroup rather than from the host's `/proc/pressure/cpu`. That's why\nnode-level CPU `full` can be nonzero here; the system-wide CPU `full` line in\n`/proc/pressure/cpu` is always zero.\n\n**Install metrics-server** for `kubectl top`. The `--kubelet-insecure-tls`\nflag is needed because kind's kubelet serving certificates are self-signed;\ndon't use it outside a local test cluster.\n\n```\nkubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/download/v0.8.0/components.yaml\n# See the previous warning about the --kubelet-insecure-tls flag!\nkubectl -n kube-system patch deployment metrics-server --type=json \\\n -p '[{\"op\":\"add\",\"path\":\"/spec/template/spec/containers/0/args/-\",\"value\":\"--kubelet-insecure-tls\"}]'\nkubectl -n kube-system rollout status deployment/metrics-server\n```\n\n**The workload**, `spinners.yaml`. Each pod starts `WORKERS` busy loops on the\nworker node:\n\n```\napiVersion: apps/v1\nkind: Deployment\nmetadata:\n name: spinners\nspec:\n replicas: 1\n selector:\n matchLabels:\n app: spinners\n template:\n metadata:\n labels:\n app: spinners\n spec:\n nodeSelector:\n kubernetes.io/hostname: psi-demo-worker\n containers:\n - name: spin\n image: busybox:1.36\n env:\n - name: WORKERS\n value: \"2\"\n command: [\"sh\", \"-c\", \"for i in $(seq $WORKERS); do (while :; do :; done) & done; wait\"]\n```\n\n**Run the three cases.** After each change, wait for the rollout to finish,\nthen about 60 seconds more, before reading `kubectl top` and the Summary API\ncommand from earlier, using `psi-demo-worker` as the node name.\n\n```\n# Run A: 2 loops on 2 CPUs\nkubectl apply -f spinners.yaml\nkubectl rollout status deployment/spinners\n\n# Run B: 6 loops on 2 CPUs\nkubectl scale deployment spinners --replicas=3\nkubectl rollout status deployment/spinners\n\n# Run C: 2 loops with a 500m limit. Scale to zero and wait 5 minutes first,\n# so avg10 and avg60 are back near zero after run B.\nkubectl scale deployment spinners --replicas=0\nsleep 300\nkubectl set resources deployment spinners --limits=cpu=500m\nkubectl scale deployment spinners --replicas=1\nkubectl rollout status deployment/spinners\n```\n\nTo get the averaged pressure for a run:\n\n```\nfor i in $(seq 12); do\n kubectl get --raw /api/v1/nodes/psi-demo-worker/proxy/stats/summary \\\n | jq '.node.cpu.psi.some.avg10'\n sleep 10\ndone | jq -s 'add / length'\n```\n\nThis prints the mean of 12 `some.avg10` readings taken about 10 seconds apart,\nthe method used for the results above.\n\nFor run C, read the throttling counters with:\n\n```\nkubectl get --raw /api/v1/nodes/psi-demo-worker/proxy/metrics/cadvisor \\\n | grep -E 'container_cpu_cfs_throttled_(periods|seconds)_total' | grep 'container=\"spin\"'\n```\n\n**Clean up:**\n\n```\nkind delete cluster --name psi-demo\ncolima stop --profile psi-demo # macOS only\n```\n\n", "url": "https://wpnews.pro/news/beyond-cpu-utilization-using-psi-to-diagnose-kubernetes-resource-contention", "canonical_source": "https://kubernetes.io/blog/2026/12/01/using-psi-to-diagnose-kubernetes-resource-contention/", "published_at": "2026-12-01 18:00:00+00:00", "updated_at": "2026-12-02 01:13:27.742596+00:00", "lang": "en", "topics": ["ai-infrastructure", "mlops", "artificial-intelligence"], "entities": ["Kubernetes", "Linux Pressure Stall Information", "kubelet", "kind", "Prometheus", "cadvisor"], "also_reported_by": [], "takeaway": "On a two-CPU node, kubectl top showed 2001m usage in both runs while CPU PSI avg10 read 0.33% with two busy loops and 99.63% with six loops competing for the same CPUs, so read node and per-pod cpu.psi from the kubelet Summary API instead of relying on utilization alone.", "recommendation": {"advice": "Alert on kubelet CPU PSI avg10 (or container_pressure_cpu_waiting_seconds_total) rather than utilization alone; the source measured 0.33% versus 99.63% pressure at identical 2001m usage.", "playbook": "production-ops", "playbook_url": "https://wpnews.pro/playbooks/production-ops"}, "alternates": {"html": "https://wpnews.pro/news/beyond-cpu-utilization-using-psi-to-diagnose-kubernetes-resource-contention", "markdown": "https://wpnews.pro/news/beyond-cpu-utilization-using-psi-to-diagnose-kubernetes-resource-contention.md", "text": "https://wpnews.pro/news/beyond-cpu-utilization-using-psi-to-diagnose-kubernetes-resource-contention.txt", "jsonld": "https://wpnews.pro/news/beyond-cpu-utilization-using-psi-to-diagnose-kubernetes-resource-contention.jsonld"}}