Q: A batch processing job is consuming all available CPU, starving other services on the same server. How do you lower its CPU priority without killing it?
Linux uses a nice value (ranging from -20 to +19) to influence CPU scheduling priority. Higher nice values mean lower priority (the proce...
#Linux #Linux / SRE — Scenario-Based Interview Questions #L2 #SRE #Systems #Troubleshooting
🎙️ Candidate Opening & Architectural Context
""During an on-call shift, our alerts triggered when a critical Linux production server exhibited this behavior. The interviewer is testing: Process scheduling, nice/renice, cgroups.. I structure my answer around systematic triage first, root cause analysis second, and permanent remediation third.""
Advertisement
🛠️ Production Runbook & Step-by-Step Resolution
1️⃣
Initial Diagnostics & Root Cause Analysis
Linux uses a nice value (ranging from -20 to +19) to influence CPU scheduling priority. Higher nice values mean lower priority (the process is "nicer" to others).
renice:renice +15 -psets the process to a low priority, allowing other processes to get CPU time first.- Starting with low priority:
nice -n 15 ./batch_job.shlaunches the process with reduced priority from the start.
2️⃣
Remediation & Permanent Safeguards
To reduce priority of a running process: For stricter enforcement, use cgroups: This limits the process to 25% of a single CPU core regardless of system load—a hard cap rather than a scheduling hint. The difference: nice is a *soft* priority hint that only matters under contention. Cgroups provide a *hard* resource limit that is enforced regardless of whether other processes need CPU.
systemd-run --scope --property=CPUQuota=25% ./batch_job.sh
💡 The Senior SRE Gold Nugget (Key Architectural Takeaway)
"Pro-Tip: renice: renice +15 -p sets the process to a low priority, allowing other processes to get CPU time first.."
⚡ 60-Second Elevator Pitch Talking Points
- renice: renice +15 -p sets the process to a low priority, allowing other processes to get CPU ti...
- Starting with low priority: nice -n 15 ./batch_job.sh launches the process with reduced priority ...
Advertisement