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 concerns. But it doesn't tell me whether workloads are waiting for CPU time.

That 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.

Industry observers note that PSI measures that waiting. Kubernetes exposes PSI through the kubelet, and the metrics are stable from Kubernetes v1.36.

It has been revealed that I wanted to see the difference for myself, so I ran the same workload in two configurations on a Kubernetes node restricted to two CPUs. In both runs, kubectl top highlighted the node using 2001m of CPU, meaning both CPUs were fully busy. But CPU pressure was 0.33% in the first run and 99.63% in the second.

CPU PSI measures how much of the time at least one task was ready to run but waiting for CPU. This is reported as some. An avg10 of 25% means that, over roughly the last 10 seconds, at least one task was waiting about a quarter of the time.

Industry observers note that the kernel reports some as averages over the last 10, 60, and 300 seconds (avg10, avg60, avg300). I use avg10, because it reacts swiftly when the workload changes. PSI also reports full, the share of time when all tasks were waiting at once; I don't use it here.

The kubelet Summary API shows CPU usage and PSI together, for the node and for each pod and container:.

Per-pod values are under .pods[].cpu.psi. If you use Prometheus, the kubelet's /metrics/cadvisor endpoint has the same signal per container, as container_pressure_cpu_waiting_seconds_total.

For the test, I used a kind cluster on a machine with four CPUs. I gave the worker node two of them and put the control plane on the other two, so the control plane didn't compete with the test workload. The workload is a small pod that runs busy loops. Each loop keeps one CPU fully busy whenever it gets one. The appendix has the full setup.

Industry observers note that in 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.

Industry observers note that run A: one pod, two loops. Two loops on two CPUs, so each loop has a CPU to itself.

According to recent reports, the worker is using 2001m, so both of its CPUs are fully busy. CPU pressure was 0.33%. The loops almost never had to wait.

Run B: three pods, six loops. Six loops now compete for the same two CPUs. Only two can run at once, so the others have to wait.

In a recent development, CPU usage is unchanged at 2001m. But CPU pressure was 99.63%: almost all the time, some loop was waiting for a CPU.

Both runs show CPU(%) as 50% because Kubernetes counts all four of the machine's CPUs as the node's capacity; it doesn't know about the two-CPU restriction.

Runs A and B use the same 2 cores on the worker node, but CPU pressure goes from under 1% to 99.6%. Run C uses a quarter of the node and still reveals 75.2% pressure.

Looking at CPU usage for the individual pods demonstrated another part of the problem:.

Recent findings suggest that in run A, the one pod used 1991m. In run B, each pod uses only 616m to 708m, even though each still runs two busy loops. The lower numbers don't mean the pods need less CPU. They're sharing two CPUs. Nothing in kubectl top reveals the waiting, but pod-level PSI does: the three pods' CPU pressure was 69%, 99.73%, and 99.79% in the last reading.

I also tested what happens when a workload has a CPU limit and the node has spare capacity. For run C, I went back to one pod with two loops and set its CPU limit to 500m.

The worker used about 0.51 of its two CPUs, leaving three quarters idle; kubectl top demonstrates 12% because Kubernetes counts four CPUs of capacity. Even so, the node's some.avg10 averaged 75.23%. The 500m limit capped the pod's CPU usage even though the worker had spare capacity. The two loops used up their CPU quota and were throttled. The container's throttling counter shows it was throttled in 1905 CFS periods since it started:.

Sources indicate that the PSI documentation uses a CPU-limited pod as its example. Here, the throttling counter points to the pod's limit rather than competition with other workloads, so adding node capacity wouldn't reduce this pressure while the pod's CPU limit stays at 500m.

The three runs show why I'd look at CPU pressure alongside utilization when investigating a performance problem:.

Sources indicate that I 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.

For 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.

In a recent development, these 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.

I ran this on kind v0.33.0 with Kubernetes v1.36.1, the release in which PSI metrics became stable.

Requirements: a Linux host with cgroup v2, a kernel with PSI enabled, Docker, kind, kubectl, and jq, with at least 4 CPUs. Check cgroup v2 and PSI on the host:.

On macOS, I used Colima, an open source tool that runs Docker Engine in a Linux VM (installable with Homebrew): colima start --profile psi-demo --runtime docker --cpu 4 --memory 8, then run the two checks inside the VM with colima ssh --profile psi-demo -- .

Create a two-node cluster with this kind-config.yaml:.

Pin the nodes to separate CPUs. Each kind node is a Docker container, so Docker can restrict which CPUs it runs on:.

Because the kind worker is a container, its node-level PSI comes from that container's cgroup rather than from the host's /proc/pressure/cpu. That's why node-level CPU full can be nonzero here; the system-wide CPU full line in /proc/pressure/cpu is always zero.

Sources indicate that install metrics-server for kubectl top. The --kubelet-insecure-tls flag is needed because kind's kubelet serving certificates are self-signed; don't use it outside a local test cluster.

In a recent development, the workload, spinners.yaml. Each pod starts WORKERS busy loops on the worker node:.

Industry observers note that run the three cases. After each change, wait for the rollout to finish, then about 60 seconds more, before reading kubectl top and the Summary API command from earlier, using psi-demo-worker as the node name.

To get the averaged pressure for a run:.

This prints the mean of 12 some.avg10 readings taken about 10 seconds apart, the method used for the results above.

For run C, read the throttling counters with:.

→ Read original article