Building Burstables: cpu slicing with cgroupsApril 29, 2025 · 6 min readMaciek SarnowiczContributorUbicloud is an open source alternative to AWS. You can self-host our software or use our managed service to reduce your cloud costs by 3x. Some of our customers told us that the price of dedicated VMs was too steep and asked for a lower entry point. We looked into it and came up with burstable VMs. These VMs run on a fraction of a shared CPU and burst to a higher level of CPU usage to support occasional spikes in usage.To implement burstable VMs, we leveraged Linux Control Groups v2 (cgroups v2), a Linux kernel feature that helps manage resource usage. We thought our open-source implementation of burstable VMs might be interesting enough to write about. We also learned a lot about Linux cgroups in the process!The building blocksLinux cgroups are organized hierarchically. Each group acts as a “container” that can host child groups, processes, and threads. These groups control specific system usage, such as cpu, io, memory, hugetlb, pids, and rdma. You can also configure cpusets to control the cpu and memory placement of Linux processes.At each group level, you can enable specific controllers to set resource limits. These resource limits apply to the group’s children (other groups and processes) and also make that controller available to the children’s groups.For example, if we enable the memory controller for a group called "webservices", we can set a memory limit of 4GB for this group. Then, any processes within this group will share this 4GB allocation. We could further create child groups like "webservices/frontend" with 1.5GB and "webservices/backend" with 2.5GB, distributing the parent's resources among children.You can use cgroups either through the virtual filesystem or through Linux’s system manager (systemd). However, not all of cgroup’s functionality is exposed through systemd. In particular, the CPU burst settings are not.Cgroups through a virtual filesystem...
First seen: 2025-05-02 17:41
Last seen: 2025-05-03 07:43