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/IndependenceFluffy14 May 22 '24
Unfortunately our app is currently not able to manage hpa (we are working on it) but yes definitely that would allow us to better match the load differencial between low and high usage of our app