📦Linux Control Groups (cgroups)
Also known as cgroups, cgroup, cgroups v2, Control Groups (Linux)
A Linux limit on memory and CPU. Each box gets its own cap.
Think of it like
Think of it like giving each child a set number of sweets. When they run out, they have to wait.
Example
Jack starts a container with a 512 MB memory cap. When his app grows past it, Linux stops the app instead of letting it slow the whole server.
Why it matters
With no limits, one busy box can take all the memory. Then every other program on the server slows down.
Definition
Example code
bash
docker run -d --memory=512m --cpus=1.5 nginxCommon mistake
Key takeaways
- 1Caps use. Memory, CPU and disk can be limited.
- 2Counts use. Tools read a container's numbers from it.
- 3Over the cap. A program past its memory cap is stopped.