Interview Prep/Linux/Processes, services and systemd

Ops wants to limit a noisy batch service to 2 CPUs and 4 GB RAM on a shared host. How?

IntermediateScenarioProcesses, services and systemd
Answer

Situation read → cgroup v2 limits via systemd.

What I'd do →

sudo systemctl set-property batch.service CPUQuota=200% MemoryMax=4G MemoryHigh=3.5G
systemctl show batch -p CPUQuotaPerSecUSec -p MemoryMax
systemd-cgtop

For ad-hoc jobs: systemd-run --scope -p CPUQuota=100% -p MemoryMax=2G ./job.sh.

Why → CPUQuota=200% equals two full CPUs; MemoryHigh throttles before MemoryMax triggers the OOM killer.

Interview tip → set-property persists by writing a drop-in; add --runtime for a temporary change.

All Linux questions Roadmap: Linux

More on Processes, services and systemd