CPU Burst lets throttled containers temporarily use extra CPU resources, improving performance and reducing latency. Alibaba Cloud Linux 2 (kernel version 4.19.91-22.al7 and later) and Alibaba Cloud Linux 3 support CPU Burst on the cgroup v1 interface.
CPU Burst is covered in Kill the Annoying CPU Throttling.
Enable CPU Burst
-
Check whether the CPU Burst global switch is enabled.
cat /proc/sys/kernel/sched_cfs_bw_burst_enabledOutput:
-
1: The global switch is enabled.NoteThe global switch is enabled by default.
-
Other value: The global switch is disabled.
To enable it, run:
sudo sh -c 'echo 1 > /proc/sys/kernel/sched_cfs_bw_burst_enabled'
-
-
Enable CPU Burst in a specific child cgroup.
NoteCPU Burst is disabled in all child cgroups by default.
-
Go to the child cgroup directory and check whether Completely Fair Scheduler (CFS) Bandwidth Controller throttling is active.
Replace
<cgroup>with your child cgroup name.cd /sys/fs/cgroup/cpu/<cgroup>/ cat cpu.cfs_period_us cat cpu.cfs_quota_usA positive return value means CFS Bandwidth Controller throttling is active. With CPU Burst enabled, the container can exceed its CPU limit.
-
Check the current default CPU Burst setting.
cat cpu.cfs_burst_usThe default value
0means CPU Burst is disabled. -
Set a value for
cpu.cfs_burst_usto enable CPU Burst.Set this parameter to a positive integer that specifies the maximum extra CPU resources the child cgroup can use in bursts. Example:
-
Set
cpu.cfs_quota_usandcpu.cfs_period_usfor the CFS Bandwidth Controller.This sets
cpu.cfs_period_usto 100 ms andcpu.cfs_quota_usto 400 ms, giving the child cgroup a steady 4-CPU allocation (cpu.cfs_quota_us/cpu.cfs_period_us).sudo sh -c 'echo 400000 > cpu.cfs_quota_us' sudo sh -c 'echo 100000 > cpu.cfs_period_us' -
Set
cpu.cfs_burst_usto enable CPU Burst.This sets
cpu.cfs_burst_usto 600 ms, allowing the child cgroup to burst up to 6 additional CPUs (cpu.cfs_burst_us/cpu.cfs_period_us).sudo sh -c 'echo 600000 > cpu.cfs_burst_us'
-
-
Query CPU Burst statistics
Go to the target child cgroup directory and view its statistics.
Replace <cgroup> with your child cgroup name.
cd /sys/fs/cgroup/cpu/<cgroup>/
cat cpu.stat
Key output fields:
-
nr_burst: Number of CPU Burst triggers. -
burst_time: Total time the child cgroup used extra CPU resources in bursts.