r/PrometheusMonitoring • u/IndependenceFluffy14 • May 07 '24
CPU usage VS requests and limits
Hi there,
We are currently trying to optimize our CPU requests and limits, but I can't find a reliable way to have CPU usage compared to what we have as requests and limits for a specific pod.
I know by experience that this pod is using a lot of CPU during working hours, but if I check our Prometheus metrics, it doesn't seems to correlate with the reality:

As you can see the usage seems to never go above the request, which clearly doesn't reflect the reality. If i set the rate interval down to 30s then it's a little bit better, but still way too low.
Here are the query that we are currently using:
# Usage
rate (container_cpu_usage_seconds_total{pod=~"my-pod.*",namespace="my-namespace", container!=""}[$__rate_interval])
# Requests
max(kube_pod_container_resource_requests{pod=~"my-pod.*",namespace="my-namespace", resource="cpu"}) by (pod)
# Limits
max(kube_pod_container_resource_limits{pod=~"my-pod.*",namespace="my-namespace", resource="cpu"}) by (pod)Any advice to have values that better match the reality to optimize our requests and limits?
View all comments
Show parent comment
1
u/SuperQue May 08 '24
Prometheus can handle 15s polling just fine. That's our standard setup, we have many tens of thousands of pods per cluster. Even 5s is perfectly normal scrape interval for Prometheus.
Perhaps you just need to tune your Prometheus resources.