Linux for Developers
/Advanced
cgroups (Control Groups)
Definition
A Linux kernel feature that limits, accounts for, and isolates the resource usage (CPU, memory, disk I/O, network) of a collection of processes.
Explain Like I'm New
The resource manager. It allows you to put a strict limit on an application, saying 'This database is never allowed to use more than 2 Gigabytes of RAM, no matter what.'
Real World Example
If you run `docker run --memory="500m" nginx`, Docker doesn't magically restrict the memory. Docker talks to the Linux Kernel and creates a `cgroup` with a 500MB limit, and puts the Nginx process inside that group.
Common Use Cases
- •Preventing apps from crashing the server via memory leaks
- •Docker resource limiting
Interview Questions
basic
- What happens if a process inside a memory-limited cgroup tries to use more RAM than it is allowed?
intermediate
- Why are cgroups critical to cloud computing providers like AWS?