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?"
Practice
Solution
Step 1: Understand QoS classes in Kubernetes
There are three main QoS classes: Guaranteed, Burstable, and BestEffort. Guaranteed means the pod has resource requests equal to limits.Step 2: Identify which class ensures resource guarantees
Guaranteed pods always get the resources they request because requests and limits match exactly.Final Answer:
Guaranteed -> Option BQuick Check:
Guaranteed = full resource guarantee [OK]
- Confusing Burstable with Guaranteed
- Thinking BestEffort has resource guarantees
- Assuming Reserved is a QoS class
Solution
Step 1: Review resource requests and limits for QoS classes
Guaranteed requires requests equal to limits. Burstable requires requests less than limits. BestEffort has no requests or limits.Step 2: Match the given specs to Burstable
resources:\n requests:\n cpu: '200m'\n memory: '128Mi'\n limits:\n cpu: '500m'\n memory: '256Mi' has requests less than limits, so it is Burstable.Final Answer:
requests less than limits -> Option AQuick Check:
Burstable = requests < limits [OK]
- Choosing equal requests and limits as Burstable
- Assuming empty resources means Burstable
- Confusing zero requests with BestEffort
resources:
requests:
cpu: '100m'
memory: '128Mi'
limits:
cpu: '100m'
memory: '128Mi'Solution
Step 1: Compare requests and limits in the pod spec
Requests and limits for both CPU and memory are equal (100m CPU and 128Mi memory).Step 2: Determine QoS class based on equality
When requests equal limits for all resources, Kubernetes assigns Guaranteed QoS.Final Answer:
Guaranteed -> Option DQuick Check:
Requests = Limits means Guaranteed [OK]
- Choosing Burstable when requests equal limits
- Thinking BestEffort applies with resource specs
- Selecting null as a QoS class
resources:
requests:
cpu: '0'
memory: '0'Solution
Step 1: Analyze the resource specification
Requests are set to cpu: '0' and memory: '0', with no limits defined.Step 2: Apply QoS classification rules
Requests are specified but zero values are treated as no requests. No limits are defined. This qualifies as BestEffort, since no resource requests or limits are effectively set.Final Answer:
BestEffort -> Option AQuick Check:
No requests or limits means BestEffort [OK]
- Thinking it causes a syntax error
- Assuming zero requests means BestEffort
- Believing it qualifies as Guaranteed
Solution
Step 1: Understand resource guarantees and bursting
Guaranteed QoS requires requests equal to limits, which means no bursting beyond limits. Burstable allows requests less than limits, enabling bursting.Step 2: Match configuration to desired behavior
Setting requests less than limits gives minimum guaranteed resources with ability to burst, which is Burstable QoS.Final Answer:
Set requests less than limits; QoS class Burstable -> Option CQuick Check:
Burstable = guaranteed minimum + burst capacity [OK]
- Choosing Guaranteed which disallows bursting
- Setting limits less than requests (invalid)
- Assuming BestEffort provides guarantees
Ready to prove it?
Pass the test and this pattern moves unknown
