0

I am using Openshift 4, CPU Request: 0.2, Limit 0.4.

From the monitoring, I can see the CPU usage started from 0.1, and increased gradually. Is it because that there is a machanisim to prevent over reserve the CPU usage?

Can I setup that the pod to use the max request CPU from the beginning, and adapt to Limit as fast as possible?

enter image description here

Jim
  • 769
  • 3
  • 10
  • 22
  • You can specify Request equal to the Limit (0.4) , than your pod shall have Limit CPU usage from the start. – Vlad Ulshin Mar 02 '22 at 18:03
  • 1
    @VladUlshin be very careful, as setting them "equal" does not mean they are "the same". CPU settings mean very different things, see [here](https://stackoverflow.com/questions/55047093/whats-the-difference-between-pod-resources-limits-and-resources-requests-in-kub/70591202#70591202) – Eugene Mar 02 '22 at 19:09

1 Answers1

2

The max limit is already available from the beginning (presuming that the node has the CPU available to give). OCP is using CFS to enforce that limit, and CFS doesn't have anything that gradually kicks in, CFS only has one thing it considers: the configured limit.

As for why you are seeing this in your monitoring, I'm not sure. But my first guess would be that that graph is using a moving average. (And thus, since it's a moving average it will converge towards the actual usage.)

David Ogren
  • 4,396
  • 1
  • 19
  • 29
  • Thank you. Yes, the monitoring figure was from the PromQL " sum(node_namespace_pod_container:container_cpu_usage_seconds_total:sum_rate{namespace='testapp', pod='testapp-worker-48-28jd9'}) by (pod) " , the PromQL range vector [5m] was hidden. If I change that to [1m], I get a very different view. Looks like all the CPU was used at beginning. – Jim Mar 03 '22 at 11:15