CPU Burst allows a container, under CPU throttling, to use additional CPU resources in bursts, improving container performance and reducing system latency. In kernel version 4.19.91-22.al7 and later, Alibaba Cloud Linux 2 and Alibaba Cloud Linux 3 support CPU Burst for the cgroup v1 interface. This topic explains how to enable CPU Burst and query its statistics.
For information about the CPU burst feature, see Kill the Annoying CPU Throttling.
Enable CPU burst
Check if the global CPU Burst switch is enabled.
cat /proc/sys/kernel/sched_cfs_bw_burst_enabledDescription about the command output:
1: The switch is enabled. This is the default setting.NoteBy default, the CPU burst feature is globally enabled for cgroup v1.
Any other value: The switch is disabled.
To enable it, run the following command:
sudo sh -c 'echo 1 > /proc/sys/kernel/sched_cfs_bw_burst_enabled'
Enable CPU Burst for a specific child cgroup.
NoteCPU Burst is disabled by default for individual child cgroups.
Navigate to the child cgroup's directory and check if CFS Bandwidth Controller throttling is active.
Replace
<cgroup>with your child cgroup's directory name.cd /sys/fs/cgroup/cpu/<cgroup>/ cat cpu.cfs_period_us cat cpu.cfs_quota_usIf
cpu.cfs_quota_usreturns a positive integer, throttling is active. CPU Burst takes effect only when throttling is active.Check the current CPU Burst setting.
cat cpu.cfs_burst_usThe default return value is
0, meaning CPU Burst is disabled.Set
cpu.cfs_burst_usto enable CPU Burst.To enable CPU Burst, set this parameter to a positive integer. This value is the maximum burstable CPU time, in microseconds, that the cgroup can accumulate. The following example shows how to enable the feature.
Configure
cpu.cfs_quota_usandcpu.cfs_period_usfor the CFS Bandwidth Controller.The following configuration sets the CPU scheduling period (
cpu.cfs_period_us) to 100 ms and the CPU quota per period (cpu.cfs_quota_us) to 400 ms. This limits the cgroup to the equivalent of 4 CPUs (400,000 / 100,000).sudo sh -c 'echo 400000 > cpu.cfs_quota_us' sudo sh -c 'echo 100000 > cpu.cfs_period_us'Configure
cpu.cfs_burst_usto enable CPU Burst.The following configuration sets the burstable CPU time to 600 ms. This enables CPU Burst and allows the cgroup to use an additional 6 CPUs' worth of processing time in a burst (
600,000 / 100,000).sudo sh -c 'echo 600000 > cpu.cfs_burst_us'
Query CPU burst statistics
To query CPU Burst statistics, navigate to the child cgroup's directory.
Replace <cgroup> with your child cgroup's directory name.
cd /sys/fs/cgroup/cpu/<cgroup>/
cat cpu.statThe key fields in the output are:
nr_burst: The total number of CPU burst events.burst_time: The total time spent using burstable CPU resources.