In a Kubernetes environment running vLLM, a high-performance inference engine for large language models, the service was configured with an excessively high CPU allocation (28 cores) despite actual CPU usage being only 0.009 cores. This led to inefficient resource utilization, as the workload was primarily GPU-bound.
Issue
The vLLM service was assigned 28 CPU cores (87.5% of system capacity) while its actual CPU usage remained as low as 9 millicores. This resulted in:
- Unnecessary resource reservation, preventing other services from utilizing available CPU capacity.
- Misalignment between CPU allocation and the GPU-centric nature of the workload.
Culprit
The over-allocation was driven by:
- Thermal distribution concerns: The CPU reservation was increased to address perceived thermal issues, rather than reflecting actual CPU usage.
- Misunderstanding of Kubernetes CPU requests: An assumption that CPU requests control physical core assignment, rather than acting as a reservation mechanism.
- Lack of awareness of Linux CFS scheduler: The scheduler automatically distributes threads across all available cores, making manual core assignment unnecessary.
Solution
Immediate Safeguards
To address the issue while respecting user preferences, the following measures were implemented:
- Memory optimization: Reduced memory limits to match actual usage (from 16Gi to 12Gi).
- Quality of Service (QoS): Set to
Guaranteed, ensuring that requests equaled limits for predictable resource allocation. - Monitoring: Added checks to verify CPU usage remained below 50 millicores and track GPU temperatures as the primary heat source.
Recommended Future Adjustments
-
Right-size CPU allocation: Align CPU requests/limits with actual usage, allowing for flexibility with minor bursts.
- Requests: 2 CPU cores (to match actual usage with a buffer).
- Limits: 4 CPU cores (to allow for occasional bursts).
- Memory: 8Gi (to reflect observed usage patterns).
-
Thermal management focus: Prioritize monitoring GPU temperatures, as they represent the primary thermal bottleneck in GPU-bound workloads.
-
Conditional scaling: Implement logic to increase CPU allocation only if actual usage exceeds a predefined threshold (e.g., 100 millicores).
Key Insights
- Kubernetes CPU requests act as reservations but do not control core assignment; this is managed by the Linux scheduler.
- GPU-bound workloads typically require minimal CPU resources, as coordination tasks are lightweight compared to GPU compute.
- Thermal management is handled by the Linux scheduler, hardware-level features like Intel Turbo Boost, and physical cooling systems, not by manual CPU allocation.
- Actual bottleneck: GPU temperature (monitored via tools like
nvidia-smi) rather than CPU usage.