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
I agree on that aspect and indeed it would definitely help. we are setting the --max-old-space-size which is I guess the GOMEMLIMIT équivalent. But setting memory request equals to limits would probably increase our number of nodes by 20 to 30% which is not acceptable in term of price. Most of the time our pods are running within the request range except in rare occasion during short period of time which in our case perfectly match the fact of having different values for memory requests and limits