Help Center/ Cloud Container Engine/ User Guide/ Scheduling/ Cloud Native Hybrid Deployment/ Resource Oversubscription Based on Pod Profiling
Updated on 2024-11-12 GMT+08:00

Resource Oversubscription Based on Pod Profiling

Volcano now supports the oversubscription algorithm based on pod profiling. The algorithm monitors the CPU and memory usage of pods on a node to estimate the node's overall resource usage. This estimation is based on statistical analysis of pod resource usage and is done with a certain level of confidence. To prevent frequent pod evictions caused by service fluctuations due to insufficient resources, the algorithm also takes into account the thresholds and fluctuations in node resource usage and calculates a stable oversubscription amount.

The pod profiling-based algorithm is superior to the real-time CPU and memory usage algorithm by preventing significant oversubscription fluctuations and insufficient coverage of resource bursts. This ensures stable service performance while still allowing for resource oversubscription.

How It Works

Resource oversubscription based on pod profiling is implemented by both the Volcano agent and scheduler. After this function is enabled, the Volcano agent periodically collects the CPU and memory usage data of pods on a node. It then calculates the average, peak, and standard deviation of each pod's CPU and memory usage, and evaluates the node's CPU and memory usage based on the statistical characteristics of the pods.

Formula for calculating oversubscribed resources: Oversubscribed node resources = (Allocated node resources - Evaluated node resource usage) x Oversubscription ratio

The oversubscription volume is periodically updated to the node's annotation so that the Volcano scheduler can schedule pods based on the oversubscription volume of each node.

Prerequisites

Dynamic resource oversubscription has been enabled. For details, see Dynamic Resource Oversubscription.

Procedure

  1. Log in to the CCE console and click the cluster name to access the cluster console.
  2. In the navigation pane, choose Nodes. On the Node Pools tab page, locate the target node pool and choose More > Mixed configuration.

    Ensure that node pool hybrid deployment and resource oversubscription are enabled. For details, see Procedure.

  3. In the navigation pane, choose Settings. On the displayed page, click the Scheduling tab. In the Default cluster scheduler area, select Volcano scheduler and enable the expert mode.

  4. On the displayed page, configure parameters.

    Parameter

    Description

    overSubscriptionMethod

    Method of calculating oversubscribed resources. The options are nodeResource and podProfile. nodeResource is the default algorithm based on node resource usage, and podProfile is the algorithm based on pod profiling.

    profilePeriod

    Interval for pod profiling, in seconds. The value ranges from 60 (1 minute) to 2592000 (1 month). If a pod's metrics are not collected for the entire period, the node's resources will be evaluated according to the resources requested by the pod.

    Therefore, no node resources will be oversubscribed when the pod profiling algorithm is initially enabled until the profiling period ends.

Use Cases

Pod profiling-based resource oversubscription disabled

  1. When configuring the expert mode, set the oversubscription_method value to nodeResource, indicating that the current cluster uses the default algorithm based on node resource usage.

  2. On the CCE console, create a Redis workload and associate it with a NodePort Service.

  3. Run the following command to increase load on the newly created Redis workload to simulate changes in service load:

    ./redis-benchmark -h <node_ip> -p 32293 -t set,get -n 3000000 -q
    sleep 30
    ./redis-benchmark -h <node_ip> -p 32293 -t set,get -n 2000000 -q
    sleep 20
    ./redis-benchmark -h <node_ip> -p 32293 -t set,get -n 2500000 -q

    In the script, replace <node_ip> with the IP address of the node in the cluster and 32293 with the node port obtained in the previous step.

  4. Check the current volume of oversubscribed resources on the node and monitor any changes.

    kubectl describe node 192.168.98.230
    Command output:
    Name:               192.168.98.230
    Roles:              <none>
    Labels:             ...
                        volcano.sh/colocation=true
                        volcano.sh/oversubscription=true
    Annotations:        ...
                        volcano.sh/oversubscription-cpu: 1103
                        volcano.sh/oversubscription-memory: 1076471825
                        ...
    CreationTimestamp:  Fri, 20 Sep 2024 16:12:33 +0800
    ...

  5. Obverse the changes in the oversubscribed resources on the node. The figure below shows the fluctuation of oversubscribed CPU resources. When the Redis workload is halted, the number of oversubscribed CPUs rises. However, it promptly drops back down once the workload resumes. If the number of oversubscribed CPUs rises and new pods are scheduled onto the node, there is a risk of CPU contention occurring when the workload restarts. This may lead to the eviction of some pods.

Pod profiling-based resource oversubscription enabled

  1. Go to the expert mode configuration page again, set oversubscription_method to podProfile, and oversubscription_profile_period to 60 for a quick demonstration. However, in practice, choose a proper profiling period based on the service's characteristics to ensure that the complete resource usage period of the service is covered.

  2. Wait for about 2 minutes for the Volcano agent to finish configuring the switchover and accumulating profile data. Then, run the command in 3 again and observe the changes in oversubscribed CPU resources.

    The figure shows that, throughout the entire script running process, the pod profiling-based algorithm takes into account the variation in pod resource usage and calculates a stable oversubscription amount. This prevents resource contention and pod eviction caused by fluctuations in pod resource usage.