1. What Are Resource Hours?
• Resource hours = requested resources × hours the workload runs.
• This is a way of expressing total reserved capacity over time.
• Example:
• You request 2 CPUs for a pod.
• It runs for 48 hours.
• Total requested CPU hours = 2 CPUs × 48 hours = 96 CPU hours.
Think of this as:
“If you booked a hotel room for 48 hours, you have 48 hours reserved, whether you sleep there or not.”
⸻
2. What’s Actual Usage?
• Kubernetes tracks CPU utilization — how much of that reserved CPU your pod actually uses.
• Example:
• Average usage = 0.5 CPU (half a CPU core) during the 48 hours.
• Total used CPU hours = 0.5 CPUs × 48 hours = 24 CPU hours.
⸻
3. How to Calculate Waste
• Waste = Requested CPU hours − Used CPU hours
• Example:
• Requested = 96 CPU hours
• Used = 24 CPU hours
• Waste = 96 − 24 = 72 CPU hours
⸻
4. Turning Waste Into Cost
Once you know the per-hour cost of a CPU, you can convert waste into dollars:
• Example cost: $0.038 per CPU hour
• Cost of waste = 72 CPU hours × $0.038 = $2.736 (~$2.7 wasted)
⸻
5. Why This Matters in Kubernetes
Kubernetes schedules resources based on your requests, not actual usage:
• If you request 2 CPUs, Kubernetes reserves that capacity for your pod — even if you’re only using 0.5 CPU.
• Over time, unused capacity is waste because:
• It blocks other workloads from using that CPU.
• If you’re paying for the cluster, you’re still paying for the reserved CPU hours.
⸻
Requested resource hours = request_amount × run_hours
Used resource hours = avg_utilization × run_hours
Waste (hours) = requested_hours − used_hours
Waste (cost) = waste_hours × price_per_hour
Recap:
Request: 2 CPUs × 48 hrs = 96 CPU hours
Usage: 0.5 CPUs × 48 hrs = 24 CPU hours
Waste: 96 − 24 = 72 CPU hours
Cost: 72 × $0.038 = $2.736
No comments:
Post a Comment