Quality of Service classes (Guaranteed, Burstable, BestEffort) in Kubernetes - Time & Space Complexity
We want to understand how Kubernetes handles resource allocation for pods with different Quality of Service (QoS) classes.
How does the system behave as the number of pods increases?
Analyze the time complexity of scheduling pods with different QoS classes.
apiVersion: v1
kind: Pod
metadata:
name: example-pod
spec:
containers:
- name: app
image: nginx
resources:
requests:
memory: "200Mi"
cpu: "500m"
limits:
memory: "500Mi"
cpu: "1"
This pod requests and limits resources, which affects its QoS class (Guaranteed, Burstable, or BestEffort).
Identify the loops, recursion, array traversals that repeat.
- Primary operation: Scheduler checks each pod's resource requests and limits to assign QoS class.
- How many times: Once per pod during scheduling, repeated for all pods in the cluster.
As the number of pods increases, the scheduler must evaluate each pod's resource specs to assign QoS.
| Input Size (n) | Approx. Operations |
|---|---|
| 10 | 10 QoS evaluations |
| 100 | 100 QoS evaluations |
| 1000 | 1000 QoS evaluations |
Pattern observation: The number of operations grows directly with the number of pods.
Time Complexity: O(n)
This means the scheduler's work to assign QoS classes grows linearly as more pods are added.
[X] Wrong: "Assigning QoS classes happens instantly regardless of pod count."
[OK] Correct: Each pod must be checked individually, so more pods mean more work for the scheduler.
Understanding how Kubernetes schedules pods and assigns QoS classes helps you explain resource management clearly in real-world scenarios.
"What if the scheduler cached QoS classes instead of recalculating each time? How would the time complexity change?"