cgroup Resource Isolation
Cap a runaway batch job without killing it, using cgroup v2 limits.
A advanced Linux challenge worth 20 points. Solve it hands-on in a real Linux environment in your browser - no local setup, no fake shells.
The Challenge
A batch analytics job eats 85% CPU on a shared host, starving the web API. Apply hard limits using cgroups without restarting either process.
Your tasks:
- Identify both PIDs: pgrep -f batch-job and pgrep -f api-server
- Create cgroup for batch job: mkdir -p /sys/fs/cgroup/batch
- Set CPU limit to 30%: echo "30000 100000" > /sys/fs/cgroup/batch/cpu.max (if cgroup v2)
or: cgcreate -g cpu:batch && cgset -r cpu.cfs_quota_us=30000 batch (if cgtools available)
- Move the batch PID into the cgroup:
echo <PID> > /sys/fs/cgroup/batch/cgroup.procs
- Write the batch PID and CPU quota to /tmp/cgroup_report.txt
- Run check to validate