Skip to content

Kubernetes Borg resource model

The Kubernetes Borg resource model refers to the specific resource management paradigm inherited from Google's Borg system, which relies on the distinction between requests and limits to achieve high resource utilization.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

In this model, users declare a relatively small requests value for the scheduler to use, while Kubernetes applies a larger limits value to the container's cgroups.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md] This design is based on the assumption that in actual production scenarios, most jobs consume resources far lower than their defined limits.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

Requests and Limits

The core of this model lies in how the two primary resource specifications are treated differently by the system components:

  • Requests: Used solely by the kube-scheduler during the scheduling phase to determine if a Node has sufficient resources.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]
  • Limits: Used by the kubelet to set the actual cgroups constraints on the running containers.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

Resource Classification

Kubernetes categorizes compute resources into two types based on how they handle resource contention:

  • Compressible Resources (e.g., CPU): When these resources are scarce, Pods will experience throttling or "starvation" but will not be terminated.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]
  • Incompressible Resources (e.g., Memory): When these resources are exhausted, Pods will be killed by the kernel via OOM (Out-Of-Memory) mechanisms.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

QoS Classes

The relationship between requests and limits determines the Pod's Quality of Service (QoS) class, which dictates how the Pod is treated during [[Eviction]] or resource starvation events^[400-devops-06-kubernetes-k8s-paas-kubernetes.md].

  • Guaranteed: Assigned when every container in the Pod has requests equal to limits for both CPU and memory^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]. These Pods are only evicted if they exceed their limits or the host is under Memory Pressure^[400-devops-06-kubernetes-k8s-paas-kubernetes.md].
  • Burstable: Assigned when at least one container has a request set (but does not meet the Guaranteed criteria)^[400-devops-06-kubernetes-k8s-paas-kubernetes.md].
  • BestEffort: Assigned when no requests or limits are set on any container within the Pod^[400-devops-06-kubernetes-k8s-paas-kubernetes.md].

Eviction priority follows the order: BestEffort < Burstable < Guaranteed.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md]

CPU Performance

A specific benefit of the Borg model is the ability to bind Pods to exclusive CPU cores (cpuset) rather than sharing CPU time.^[400-devops-06-kubernetes-k8s-paas-kubernetes.md] To enable this feature, the Pod must be of the Guaranteed QoS class with an integer value for CPU requests and limits^[400-devops-06-kubernetes-k8s-paas-kubernetes.md].

Sources

  • 400-devops-06-kubernetes-k8s-paas-kubernetes.md