Right-Sizing Resources
What You'll Learn
You'll learn practical strategies for setting appropriate CPU and memory requests and limits by analyzing application behavior and monitoring data.
Why Right-Sizing Matters
Right-sizing is the process of adjusting resource requests and limits to match what your application actually needs—not too generous (wasting cluster capacity) and not too stingy (causing throttling or OOMKilled events). Think of it like tailoring clothes: off-the-rack might fit, but custom measurements ensure the perfect balance of comfort and efficiency.
The Right-Sizing Process
Start with Monitoring Data
Use your monitoring tools to track actual CPU and memory usage over time. Look at:
- Average usage during normal operations
- Peak usage during traffic spikes
- Resource consumption patterns (steady vs. bursty)
Set Requests Based on Typical Usage
Your requests should reflect what the application consistently needs. Set CPU requests slightly above average usage and memory requests at the 75th-90th percentile of observed consumption. This ensures the scheduler places your pod on a node with adequate resources.
Set Limits with Headroom
Your limits should allow for peaks without being wasteful. A common starting point: CPU limits 1.5-2× requests (or no limit for non-critical apps), memory limits at the 95th-99th percentile of observed usage to prevent rare spikes from causing OOMKilled events.
Iterate Based on QoS Class
Review which Quality of Service class your pods fall into. If you're getting Burstable when you need Guaranteed, adjust accordingly. If you're overprovisioning for Guaranteed, consider whether Burstable is acceptable.
Monitor and Adjust Continuously
Right-sizing isn't one-and-done. As your application evolves, traffic patterns change, and dependencies shift, revisit your resource settings quarterly or after major updates.
Key Takeaway: Right-sizing resources requires ongoing analysis of monitoring data to set requests that reflect typical needs and limits that accommodate peaks, balancing cluster efficiency with application reliability.