Cloud and Container Basics
resources:
requests:
cpu: 500m
limits:
cpu: 1000mIn a Deployment whose Pod containers have the settings above, four Pods are running, each using 400m (0.4 cores) of CPU. The HorizontalPodAutoscaler's target CPU utilization is 60%, and the required number of Pods is computed as ⌈current number × current utilization ÷ target utilization⌉. Which of the following is the required number of Pods?
- A3
- B5
- C6
Show answer and explanation
Answer: C. 6
The CPU utilization used by a HorizontalPodAutoscaler is a percentage of requests, not of limits. Each Pod uses 400m ÷ 500m = 80%, so the required number is 4 × 80 ÷ 60 = 5.33…, which rounds up to 6. With 6 Pods, the total usage of 400m × 4 = 1,600m is shared at about 267m each, a utilization of about 53%, below the target. If requests are not set, autoscaling based on CPU utilization does not work.
- A. This uses the 40% utilization relative to the limit (1000m) (4 × 40 ÷ 60 = 2.67…, rounded up). Utilization is based on requests.
- B. This rounds 5.33… down. With 5 Pods each would use 1,600m ÷ 5 = 320m, a utilization of 64%, above the 60% target.
- C. Correct. With 80% utilization, 4 × 80 ÷ 60 = 5.33… rounds up to 6.