Given a Pod defining a container that runs a single-threaded application, and a CPU limit value of 1
:
apiVersion: v1
kind: Pod
metadata:
name: single-threaded-workload
spec:
containers:
- name: microservice
image: single-threaded-workload
resources:
limits:
cpu: "1"
requests:
cpu: 250m
Would the single-threaded application ever be CPU throttled?
Would increasing the CPU limit value to higher than 1
provide any performance benefit?
(This is assuming the container only has 1 active thread running)
CPU limits are not actually related to the available CPUs on the machine, but to the CFS (Compute Fair Scheduling) which is a mechanism used to determine how much CPU time can process consume. In short, limits: 1 CPU
means that your process can consume the whole scheduler period (by default 100ms), it does not matter whether it consumes the whole period on a single CPU (1x100ms) or 2 half-periods (2x50ms=100ms) on two CPUs.
It is quite well explained in this article: https://wbhegedus.me/understanding-kubernetes-cpu-limits/