Este contenido no está disponible en el idioma seleccionado.
Chapter 19. Provisioning real-time and low latency workloads
To achieve low latency and consistent response times for OpenShift Container Platform applications, use the Node Tuning Operator. This Operator implements automatic tuning to optimize your cluster for high-performance computing workloads.
You use the performance profile configuration to make these changes.
You can update the kernel to kernel-rt, reserve CPUs for cluster and operating system housekeeping duties, including pod infra containers, isolate CPUs for application containers to run the workloads, and disable unused CPUs to reduce power consumption.
When writing your applications, follow the general recommendations described in RHEL for Real Time processes and threads.
19.1. Scheduling a low latency workload onto a compute node Copiar enlaceEnlace copiado en el portapapeles!
To run low latency workloads, schedule them onto a compute node associated with a performance profile that configures real-time capabilities. This ensures that the node is tuned to meet the specific timing and performance requirements of your application.
To schedule a workload on specific nodes, use label selectors in the Pod custom resource (CR). The label selectors must match the nodes that are attached to the machine config pool that was configured for low latency by the Node Tuning Operator.
Prerequisites
-
You have installed the OpenShift CLI (
oc). -
You have logged in as a user with
cluster-adminprivileges. - You have applied a performance profile in the cluster that tunes compute nodes for low latency workloads.
Procedure
Create a
PodCR for the low latency workload and apply it in the cluster, for example:Example
Podspec configured to use real-time processingCopy to Clipboard Copied! Toggle word wrap Toggle overflow where
metadata.annotations.cpu-quota.crio.io- Disables the CPU completely fair scheduler (CFS) quota at the pod run time.
metadata.annotations.cpu-load-balancing.crio.io- Disables CPU load balancing.
metadata.annotations.irq-load-balancing.crio.io- Opts the pod out of interrupt handling on the node.
spec.nodeSelector.node-role.kubernetes.io/worker-cnf-
The
nodeSelectorlabel must match the label that you specify in theNodeCR. spec.runtimeClassName-
runtimeClassNamemust match the name of the performance profile configured in the cluster.
-
Enter the pod
runtimeClassNamein the form performance-<profile_name>, where <profile_name> is thenamefrom thePerformanceProfileYAML. In the previous YAML example, thenameisperformance-dynamic-low-latency-profile. Ensure the pod is running correctly. Status should be
running, and the correctcnf-workernode should be set.oc get pod -o wide
$ oc get pod -o wideCopy to Clipboard Copied! Toggle word wrap Toggle overflow Expected output
NAME READY STATUS RESTARTS AGE IP NODE dynamic-low-latency-pod 1/1 Running 0 5h33m 10.131.0.10 cnf-worker.example.com
NAME READY STATUS RESTARTS AGE IP NODE dynamic-low-latency-pod 1/1 Running 0 5h33m 10.131.0.10 cnf-worker.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Get the CPUs that the pod configured for IRQ dynamic load balancing runs on:
oc exec -it dynamic-low-latency-pod -- /bin/bash -c "grep Cpus_allowed_list /proc/self/status | awk '{print $2}'"$ oc exec -it dynamic-low-latency-pod -- /bin/bash -c "grep Cpus_allowed_list /proc/self/status | awk '{print $2}'"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Expected output
Cpus_allowed_list: 2-3
Cpus_allowed_list: 2-3Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Ensure the node configuration is applied correctly.
Log in to the node to verify the configuration.
oc debug node/<node-name>
$ oc debug node/<node-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that you can use the node file system:
chroot /host
sh-4.4# chroot /hostCopy to Clipboard Copied! Toggle word wrap Toggle overflow Expected output
sh-4.4#
sh-4.4#Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure the default system CPU affinity mask does not include the
dynamic-low-latency-podCPUs, for example, CPUs 2 and 3.cat /proc/irq/default_smp_affinity
sh-4.4# cat /proc/irq/default_smp_affinityCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
33
33Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure the system IRQs are not configured to run on the
dynamic-low-latency-podCPUs:find /proc/irq/ -name smp_affinity_list -exec sh -c 'i="$1"; mask=$(cat $i); file=$(echo $i); echo $file: $mask' _ {} \;sh-4.4# find /proc/irq/ -name smp_affinity_list -exec sh -c 'i="$1"; mask=$(cat $i); file=$(echo $i); echo $file: $mask' _ {} \;Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
Copy to Clipboard Copied! Toggle word wrap Toggle overflow WarningWhen you tune nodes for low latency, the usage of execution probes in conjunction with applications that require guaranteed CPUs can cause latency spikes. Use other probes, such as a properly configured set of network probes, as an alternative.
19.2. Creating a pod with a guaranteed QoS class Copiar enlaceEnlace copiado en el portapapeles!
You can create a pod with a quality of service (QoS) class of Guaranteed for high-performance workloads. Configuring a pod with a QoS class of Guaranteed ensures that the pod has priority access to the specified CPU and memory resources.
To create a pod with a QoS class of Guaranteed, you must apply the following specifications:
- Set identical values for the memory limit and memory request fields for each container in the pod.
- Set identical values for CPU limit and CPU request fields for each container in the pod.
In general, a pod with a QoS class of Guaranteed will not be evicted from a node. One exception is during resource contention caused by system daemons exceeding reserved resources. In this scenario, the kubelet might evict pods to preserve node stability, starting with the lowest priority pods.
Prerequisites
-
Access to the cluster as a user with the
cluster-adminrole. -
The OpenShift CLI (
oc).
Procedure
Create a namespace for the pod by running the following command:
oc create namespace qos-example
$ oc create namespace qos-exampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow qos-example: Specifies a
qos-exampleexample namespace.Example output
namespace/qos-example created
namespace/qos-example createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create the
Podresource:Create a YAML file that defines the
Podresource:Example
qos-example.yamlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow where:
spec.containers.image-
Specifies public image, such as the
hello-openshiftimage. spec.containers.resources.limits.memory- Specifies a memory limit of 200 MB.
spec.containers.resources.limits.cpu- Specifies a CPU limit of 1 CPU.
spec.containers.resources.requests.memory- Specifies a memory request of 200 MB.
spec.containers.resources.requests.cpuSpecifies a CPU request of 1 CPU.
NoteIf you specify a memory limit for a container, but do not specify a memory request, OpenShift Container Platform automatically assigns a memory request that matches the limit. Similarly, if you specify a CPU limit for a container, but do not specify a CPU request, OpenShift Container Platform automatically assigns a CPU request that matches the limit.
Create the
Podresource by running the following command:oc apply -f qos-example.yaml --namespace=qos-example
$ oc apply -f qos-example.yaml --namespace=qos-exampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
pod/qos-demo created
pod/qos-demo createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
View the
qosClassvalue for the pod by running the following command:oc get pod qos-demo --namespace=qos-example --output=yaml | grep qosClass
$ oc get pod qos-demo --namespace=qos-example --output=yaml | grep qosClassCopy to Clipboard Copied! Toggle word wrap Toggle overflow Example output
qosClass: Guaranteed
qosClass: GuaranteedCopy to Clipboard Copied! Toggle word wrap Toggle overflow
19.3. Disabling CPU load balancing in a Pod Copiar enlaceEnlace copiado en el portapapeles!
To optimize performance, disable or enable CPU load balancing for your Pods. CRI-O implements this functionality and applies the configuration only when specific requirements are met.
Functionality to disable or enable CPU load balancing is implemented on the CRI-O level. The code under the CRI-O disables or enables CPU load balancing only when the following requirements are met.
The pod must use the
performance-<profile-name>runtime class. You can get the proper name by looking at the status of the performance profile, as shown here:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The Node Tuning Operator is responsible for the creation of the high-performance runtime handler config snippet under relevant nodes and for creation of the high-performance runtime class under the cluster. It will have the same content as the default runtime handler except that it enables the CPU load balancing configuration functionality.
To disable the CPU load balancing for the pod, the Pod specification must include the following fields:
Only disable CPU load balancing when the CPU manager static policy is enabled and for pods with guaranteed QoS that use whole CPUs. Otherwise, disabling CPU load balancing can affect the performance of other containers in the cluster.
19.4. Disabling power saving mode for high priority pods Copiar enlaceEnlace copiado en el portapapeles!
To protect high priority workloads when using power saving configurations on a node, apply performance settings at the pod level. This ensures that the configuration applies to all cores used by the pod, maintaining performance stability.
By disabling P-states and C-states at the pod level, you can configure high priority workloads for best performance and lowest latency.
| Annotation | Possible Values | Description |
|---|---|---|
|
|
|
This annotation allows you to enable or disable C-states for each CPU. Alternatively, you can also specify a maximum latency in microseconds for the C-states. For example, enable C-states with a maximum latency of 10 microseconds with the setting |
|
|
Any supported |
Sets the |
Prerequisites
- You have configured power saving in the performance profile for the node where the high priority workload pods are scheduled.
Procedure
Add the required annotations to your high priority workload pods. The annotations override the
defaultsettings.Example high priority workload annotation
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Restart the pods to apply the annotation.
19.5. Disabling CPU CFS quota Copiar enlaceEnlace copiado en el portapapeles!
To prevent CPU throttling for latency-sensitive workloads, disable the CPU CFS quota. This configuration allows pods to use unallocated CPU resources on the node, ensuring consistent application performance.
Procedure
To eliminate CPU throttling for pinned pods, create a pod with the
cpu-quota.crio.io: "disable"annotation. This annotation disables the CPU completely fair scheduler (CFS) quota when the pod runs.Example pod specification with
cpu-quota.crio.iodisabledCopy to Clipboard Copied! Toggle word wrap Toggle overflow NoteOnly disable CPU CFS quota when the CPU manager static policy is enabled and for pods with guaranteed QoS that use whole CPUs. For example, pods that contain CPU-pinned containers. Otherwise, disabling CPU CFS quota can affect the performance of other containers in the cluster.
19.6. Disabling interrupt processing for CPUs where pinned containers are running Copiar enlaceEnlace copiado en el portapapeles!
To achieve low latency for workloads, some containers require that the CPUs they are pinned to do not process device interrupts. You can use the irq-load-balancing.crio.io pod annotation to control whether device interrupts are processed on CPUs where the pinned containers are running.
To disable interrupt processing for CPUs where containers belonging to individual pods are pinned, ensure that globallyDisableIrqLoadBalancing is set to false in the performance profile. In the pod specification, set the irq-load-balancing.crio.io pod annotation to disable, as demonstrated in the following example: