robusta-dev / krr

Prometheus-based Kubernetes Resource Recommendations
MIT License
3.05k stars 160 forks source link

[Algoithm] CPU request recommandation detail calculation #348

Open mwilfried opened 1 month ago

mwilfried commented 1 month ago

Describe the bug Sorry, it's not a bug but much more a request for more explanations about the request recommendations. The documentation says

For CPU, we set a request at the 95th percentile with no limit. Meaning, in 95% of the cases, your CPU request will be sufficient. For the remaining 5%, we set no limit. This means your pod can burst and use any CPU available on the node - e.g. CPU that other pods requested but aren’t using right now.

I understand that if my pod has one container, and consumes 1 core, the request recommendation will be to set a cpu request of 50m ? Is that right ?

Could you explicit a little bit more how the CPU Request recommendation is calculating by giving some examples. It would be very helpful

Regards

aantn commented 1 month ago

Hi @mwilfried, we set the CPU to the 95th percentile of usage. Meaning, if your pod consumed 1 core constantly, we would set a request of 1 core (1000m) as the 95th percentile of constant 1 core usage is 1 core.

If 95% of the time your pod used half a core (500m) or under, but 5% of the time it spiked to 1 full core, we would set 500m as that is the 95th percentile value.

Does that help?

mwilfried commented 1 month ago

Hi @aantn

thank you for your reply. "95th percentile of usage" ==> on other words, it's an average of usage for 95% of time for a period, am I right ?

Yes more clear, thank you

aantn commented 1 month ago

Close! It's the "the maximum value 95% of the time".

See https://simple.wikipedia.org/wiki/Percentile for more info