Skip to content

Demystifying Three QoS Classes in Kubernetes: A Guide for Efficient Resource Management

Last updated on November 22, 2023

In the world of Kubernetes, Quality of Service (QoS) plays a vital role in ensuring optimal resource allocation and performance. Kubernetes offers three distinct QoS classes: Guaranteed, Burstable, and BestEffort. Understanding these classes and their implications is crucial for efficient resource management and maintaining a healthy cluster. In this blog post, we’ll dive into each QoS class, exploring their characteristics, use cases, and best practices.

Guaranteed QoS Class

The Guaranteed QoS class is the highest priority class in Kubernetes. Pods assigned to this class are guaranteed the requested CPU and memory resources, which are reserved exclusively for them. This ensures that the pod will not be evicted due to resource constraints, providing predictable and reliable performance. Guaranteed QoS is typically suitable for critical workloads such as databases or other important system components.

Key characteristics:

  • Exclusive resource allocation for pods.
  • Pods are guaranteed to have the requested resources available at all times.
  • Pods are prioritised over other QoS classes when it comes to resource allocation.

Best practices:

  • Specify accurate resource requests and limits to ensure efficient utilisation.
  • Regularly monitor and adjust resource requests based on workload behavior.
  • Avoid overcommitting resources to prevent potential resource exhaustion.
apiVersion: v1
kind: Pod
metadata:
  name: critical-pod
spec:
  containers:
  - name: app
    image: my-critical-app
    resources:
      requests:
        memory: "1Gi"
        cpu: "500m"
      limits:
        memory: "2Gi"
        cpu: "1"

In this example, the “critical-pod” is assigned to the Guaranteed QoS class. The pod specifies resource requests and limits for both memory and CPU, ensuring that it receives the requested resources exclusively.

Burstable QoS Class

The Burstable QoS class is the intermediate class in Kubernetes, providing a balance between resource guarantees and flexibility. Pods assigned to this class receive the requested resources, but they can also consume additional resources when available. However, if the cluster faces resource contention, pods in the Burstable class may be evicted to free up resources for higher priority pods.

Key characteristics:

  • Pods receive the requested resources but can consume additional resources when available.
  • Pods can be evicted if resource contention occurs.

Best practices:

  • Set appropriate resource requests and limits to allow flexibility while preventing excessive resource consumption.
  • Implement resource quotas to avoid excessive resource usage by pods in this class.
  • Monitor resource utilization regularly to ensure efficient resource allocation.
apiVersion: v1
kind: Pod
metadata:
  name: burstable-pod
spec:
  containers:
  - name: app
    image: my-burstable-app
    resources:
      requests:
        memory: "512Mi"
        cpu: "250m"

In this example, the “burstable-pod” is assigned to the Burstable QoS class. The pod specifies resource requests for memory and CPU, allowing flexibility for additional resource consumption if available, but there are no explicit limits defined.

BestEffort QoS Class

The BestEffort QoS class is the lowest priority class in Kubernetes. Pods in this class have no resource guarantees and can consume any available resources within the cluster. They are the first to be evicted if the cluster faces resource constraints. BestEffort is often used for non-critical or low-priority workloads where resource guarantees are not essential.

Key characteristics:

  • No resource guarantees for pods.
  • Pods can consume any available resources within the cluster.
  • Pods are the first to be evicted if resource contention occurs.

Best practices:

  • Use BestEffort for non-critical workloads or tasks with low resource requirements.
  • Avoid relying on pods in this class for important system components.
  • Regularly monitor resource usage to identify potential resource bottlenecks.
apiVersion: v1
kind: Pod
metadata:
  name: besteffort-pod
spec:
  containers:
  - name: app
    image: my-besteffort-app

In this example, the “besteffort-pod” is assigned to the BestEffort QoS class. The pod does not specify any resource requests or limits, allowing it to consume any available resources within the cluster.

Understanding the three QoS classes in Kubernetes is vital for efficient resource management and ensuring optimal performance of your applications. By appropriately assigning pods to the appropriate QoS class, you can strike a balance between resource guarantees and flexibility, allowing your cluster to handle various workloads effectively. Remember to regularly monitor resource utilisation and adjust resource requests as needed to maintain a healthy and efficient Kubernetes environment.

Published inAutomationKubernetesLinux