☸️Specify CPU & MEMORY - Request & Limit
In Kubernetes (and computing in general), 1 vCPU means 1 virtual Central Processing Unit.
What is 1 vCPU?
- vCPU stands for Virtual CPU.
- In a virtualized environment like AWS EC2 or Kubernetes, a vCPU represents a portion of the physical CPU resources allocated to a virtual machine or container.
- 1 vCPU = 1 Physical CPU Core or 1 Hyperthread (in many cases, especially with Intel and AMD processors using Hyper-Threading).
In Kubernetes:
- Kubernetes abstracts compute resources using vCPUs.
- 1 vCPU in Kubernetes is equivalent to 1 CPU core on the underlying node.
- You can request or limit vCPU usage using resources.requests.cpu and resources.limits.cpu.
Example
resources:
requests:
cpu: "1" # Request 1 vCPU
memory: "2Gi"
limits:
cpu: "2" # Limit to 2 vCPUs
memory: "4Gi"
Key Takeaways
- 1 vCPU is equivalent to 1 CPU core or 1 hyperthread depending on the hardware.
- Kubernetes uses millicores for fractional CPU requests (e.g., 500m = 0.5 vCPU).
- Nodes (e.g., EC2 instances) provide the actual CPU capacity that pods consume.
- Efficient CPU allocation through proper requests and limits ensures stable application performance.