How Do Linux Control Groups Limit Resources?

Server resources divided among isolated application workloads with monitored limits

Linux Control Groups Explainer

Linux control groups, commonly called cgroups, organize processes into a hierarchy and let the kernel manage their resource use as groups. A service manager or container runtime can place related processes in one cgroup instead of tracking every descendant separately. Controllers expose policies for resources such as CPU time, memory, block-device input-output, and process counts. The result is not a second machine; it is accounting and control applied to workloads that still share one kernel and the underlying hardware.

In cgroup version 2, processes occupy nodes in a single unified hierarchy. A child normally belongs beneath a parent whose resource domain it shares. Administrators enable selected controllers for descendants and write limits or weights through files in the cgroup file system. Moving a process changes which group’s policies account for its future activity. New child processes generally remain in the parent’s cgroup unless software deliberately moves them, allowing a service and its worker processes to be governed together.

CPU controls can express relative weight or a hard quota over a time period. A weight matters when groups compete: one group receives a larger share than another, but idle capacity need not go unused. A quota caps how much CPU time the group may consume during each period and can throttle it even when processors are otherwise free. Separate controls can constrain which CPUs are eligible. These mechanisms shape scheduling; they do not promise a particular application response time when locks, storage, or network dependencies become bottlenecks.

Memory control tracks pages charged to the group and provides several thresholds. A high boundary can apply reclaim pressure before a hard maximum is reached. At a maximum, allocation and reclaim behavior may lead to out-of-memory handling within the cgroup rather than allowing unlimited growth across the host. Swap and memory-event counters provide additional visibility. Accurate policy requires headroom for runtime overhead, page cache, and bursts; a limit set exactly to an application’s expected data size can cause repeated reclaim or abrupt failure.

Input-output controllers can weight or cap traffic to particular devices, while a process-count controller limits how many tasks a group may create. Pressure metrics show when workloads stall waiting for CPU, memory, or I/O. Limits interact: throttling CPU can slow cleanup and increase memory retention, while storage congestion can grow queues. Delegation also needs strict ownership so an unprivileged manager can create descendants without gaining control over unrelated processes or escaping ancestor limits.

Cgroups are frequently paired with namespaces in containers, but they solve different problems. Namespaces change what a process can see; cgroups govern how much of shared resources it can use. Neither is a complete security boundary by itself. Operators should set measured limits, monitor throttling and pressure, define restart behavior, and test overload rather than relying on defaults. They must also understand which layer owns the hierarchy so a container runtime, service manager, and manual scripts do not conflict. Cgroups provide a disciplined resource tree: processes are grouped by workload, controllers account for their combined consumption, and parent policies constrain descendants so one busy service is less able to overwhelm everything else on the host.

Accounting follows hierarchy semantics rather than business labels. A parent’s totals include work in its descendants, and a child cannot escape limits imposed above it. Threaded cgroups support specialized arrangements for controllers that operate at thread granularity, but they add rules that general service managers normally hide. Resource values should be interpreted with workload context: a high CPU percentage can be healthy throughput, while modest usage accompanied by pressure stalls may indicate starvation. Dashboards that show limits, current consumption, throttling, reclaim, and failure events together are far more useful than a single utilization graph.

Linux cgroups organize processes into a hierarchy where controllers account for and regulate shared resources. Key terms include cgroup v2, hierarchy, controller, descendant, CPU weight, quota, memory high, memory max, I/O limit, process count, pressure, and delegation.

A weight divides a contested resource proportionally and can allow a group to use idle capacity. A hard limit or quota caps consumption even when more capacity is available, which provides stronger isolation but can throttle work.

No. Cgroups control and account for resources. Containers typically combine cgroups with namespaces, file-system setup, privileges, and runtime policy. Sharing the host kernel means each layer still needs secure configuration.

Explore more "Explainers"

Discover additional explainers across politics, science, business, technology, and other fields. Each explainer breaks down a complex idea into clear, everyday language—helping you better understand how major concepts, systems, and debates shape the world around us.