Kubernetes CPU throttling: why your app is slow under a CPU limit
Reproduced on k3s v1.31.5 (k3d) with kubectl v1.36.1 on a cgroup v2 node, with the metrics-server v0.7.2 that ships with k3s.
What you see
$ kubectl top pod -n lab
NAME CPU(cores) MEMORY(bytes)
cpu-burn 101m 0Mi
cpu-free 997m 0Mi
$ kubectl top node
NAME CPU(cores) CPU(%) MEMORY(bytes) MEMORY(%)
k3d-kg-lab-b-server-0 945m 6% 1295Mi 16%
$ kubectl get pod cpu-burn -n lab -o jsonpath='{.spec.containers[0].resources}'
{"limits":{"cpu":"100m","memory":"32Mi"},"requests":{"cpu":"100m","memory":"32Mi"}}
$ kubectl exec cpu-burn -n lab -- cat /sys/fs/cgroup/cpu.max
10000 100000
$ kubectl exec cpu-burn -n lab -- cat /sys/fs/cgroup/cpu.stat
usage_usec 275204
user_usec 257297
system_usec 17907
nice_usec 0
nr_periods 26
nr_throttled 26
throttled_usec 320211
nr_bursts 0
burst_usec 0
$ kubectl exec cpu-free -n lab -- cat /sys/fs/cgroup/cpu.max
max 100000
$ kubectl exec cpu-free -n lab -- cat /sys/fs/cgroup/cpu.stat
usage_usec 2834771
user_usec 2818773
system_usec 15998
nice_usec 0
nr_periods 0
nr_throttled 0
throttled_usec 0
nr_bursts 0
burst_usec 0
# The same shell loop in a pod with no CPU limit, then in one with a 100m limit
$ kubectl exec unlimited -n lab -- sh -c 'time sh -c "i=0; while [ \$i -lt 300000 ]; do i=\$((i+1)); done"'
real 0m 0.43s
user 0m 0.43s
sys 0m 0.00s
$ kubectl exec limited -n lab -- sh -c 'time sh -c "i=0; while [ \$i -lt 300000 ]; do i=\$((i+1)); done"'
real 0m 3.59s
user 0m 0.36s
sys 0m 0.00s
$ kubectl exec limited -n lab -- cat /sys/fs/cgroup/cpu.stat
usage_usec 389104
user_usec 375074
system_usec 14030
nice_usec 0
nr_periods 40
nr_throttled 36
throttled_usec 2610272
nr_bursts 0
burst_usec 0What it means
The kubelet turns resources.limits.cpu into a CFS quota on the container's cgroup. On a cgroup v2 node you can read it in /sys/fs/cgroup/cpu.max. A limit of 100m shows as 10000 100000, which is 10000 microseconds of CPU time in every 100000 microsecond period.
When the container's processes use up the quota early in a period, the kernel stops running them until the next period. cpu.stat counts this. nr_periods is the number of periods with activity, nr_throttled is how many of them hit the quota and throttled_usec is the total time spent paused.
Throttling never kills or restarts the pod. Nothing shows in kubectl get pods or in the events. In our lab the same shell loop took several times longer in a pod with a 100m limit than in a pod with no limit. The CPU time it used was about the same. Only the wall clock time grew.
Common causes
The CPU limit is below what the app needs at peak
The limit was set from average use, or copied from another service. Under load the app needs more CPU than the quota allows and every request waits for the next period.
How to tell: kubectl top pod shows CPU sitting at the limit. nr_throttled and throttled_usec grow between two reads of cpu.stat.
Many threads share one quota
The quota is per container, not per thread. A runtime with many threads, such as the JVM or Go, can use the whole quota in a short burst at the start of a period and then wait for the rest of it.
How to tell: nr_throttled keeps growing while the average CPU in kubectl top looks well below the limit.
Startup needs more CPU than steady state
JIT compilation, loading classes and warming caches need a burst of CPU. Under a tight limit the start is slow and probes can fail before the app is ready.
How to tell: Slow starts and probe failures right after each start. The app behaves once it is warm.
A LimitRange added a limit nobody chose
A LimitRange in the namespace gives a default CPU limit to every container that does not set one. The team may not know the pod has a limit at all.
How to tell: kubectl describe pod shows a cpu limit that is not in your manifest. kubectl describe limitrange shows it as the Default Limit.
It is not throttling
If the pod has no CPU limit, or is not near it, the slowness comes from somewhere else. The node may be short of CPU, or the app may be waiting on a database, the network or locks.
How to tell: cpu.max reads max, or nr_throttled does not grow. kubectl top node shows a busy node, or the app's own traces show time spent waiting.
How to diagnose it
kubectl top pod <pod> -n <namespace> --containersCompare CPU(cores) with the limit. In our lab a busy loop under a 100m limit showed 101m and never more, while a pod with no limit used close to a full core.
kubectl get pod <pod> -n <namespace> -o jsonpath='{.spec.containers[*].resources}'Shows the requests and limits the pod really runs with, including defaults added by a LimitRange.
kubectl exec <pod> -n <namespace> -- cat /sys/fs/cgroup/cpu.maxThe quota and the period in microseconds. max means there is no CPU limit, so the container cannot be throttled by its quota.
kubectl exec <pod> -n <namespace> -- cat /sys/fs/cgroup/cpu.statRead it twice a short time apart. If nr_throttled and throttled_usec grow, the container is being throttled now. On a cgroup v1 node the file is /sys/fs/cgroup/cpu/cpu.stat and the time is throttled_time in nanoseconds.
kubectl top nodeIf the node has plenty of spare CPU while the pod sits at its limit, the limit is the bottleneck, not the node.
kubectl describe limitrange -n <namespace>A Default Limit for cpu here is applied to every container in the namespace that sets no limit of its own.
How to fix it
Raise the CPU limit
Set the limit above the real peak, not the average. Read cpu.stat again after the change to check that nr_throttled stops climbing.
kubectl set resources deployment <name> -n <namespace> --limits=cpu=<new-limit>Trade-off: A higher limit lets one pod take more of the node's spare CPU. The scheduler only plans for requests, so pods that burst at the same moment can still slow each other down.
Remove the CPU limit and keep the request
The request still gives the pod its fair share when the node is busy. Without a limit it can also use CPU that would otherwise sit idle.
Trade-off: A pod with a bug that spins the CPU can take all the spare CPU on the node. The pod also leaves the Guaranteed QoS class, which matters if you rely on it, for example for CPU pinning with the static CPU manager.
Match the thread count to the limit
Tell the runtime how much CPU it really has, so fewer threads compete for the same quota. Go 1.25 and later read the cgroup limit for GOMAXPROCS. For older Go, set GOMAXPROCS from the limit.
env:
- name: GOMAXPROCS
valueFrom:
resourceFieldRef:
resource: limits.cpuTrade-off: Fewer threads can lower throughput for work that mostly waits on I/O. Test under real load before and after.
How to stop it coming back
- Set CPU requests from measured use and treat the limit as a guard, not a target.
- Graph throttled periods per container, such as container_cpu_cfs_throttled_periods_total from cAdvisor, next to latency.
- Load test with the same CPU limit you run in production.
- Check namespace LimitRange defaults so no container gets a CPU limit nobody chose.
How KubeGraf investigates it
Agents propose competing explanations and cite the evidence behind each one. How KubeGraf handles Kubernetes incidents.
Frequently asked questions
Do CPU limits cause throttling in Kubernetes?
Yes. A CPU limit becomes a CFS quota on the container's cgroup. When the container uses its quota for the period, it waits until the next one, even if the node has idle CPU.
What is CFS throttling?
CFS is the Linux CPU scheduler. Its quota gives a cgroup a set amount of CPU time in each period. Throttling is the time the cgroup spends paused after it has used that amount.
How do I check if a pod is CPU throttled?
Run kubectl exec to read /sys/fs/cgroup/cpu.stat inside the container twice. If nr_throttled and throttled_usec grow between reads, it is being throttled. kubectl top pod showing CPU at the limit is another sign.
Should I remove CPU limits?
Removing the limit stops throttling and keeps the request as the pod's guaranteed share. The cost is that a runaway pod can use all spare CPU on the node and the pod leaves the Guaranteed QoS class.
Last updated . Try KubeGraf Freemium.
Related
- Liveness probe failed / Readiness probe failed
- OOMKilled
- Pending (FailedScheduling)
- The service is slow and nothing is broken
- How do I set Kubernetes requests and limits correctly?
- Kubernetes Cost Optimization in 2026: The DevOps Engineer's Guide to Cutting Cloud Spend Without Touching Workloads