mercari / tortoise

Tortoise: Shell-Shockingly-Good Kubernetes Autoscaling
MIT License
316 stars 14 forks source link

add addtional resources on top of VPA recommendation for less frequent scaling up #383

Closed sanposhiho closed 3 months ago

sanposhiho commented 3 months ago

What this PR does / why we need it:

This PR changes how Tortoise changes the resource requests.

Previously, we calculated the ideal size just by (VPA recommendation) * (1+buffer ratio). (buffer ratio is 0.1, by default) But, then every time VPA's recommendation changes, vertical scaling could happen, which increases the frequency of vertical scaling depending on the service's nature, especially scaling up because scaling down is limited to happening only once an hour anyways.

This PR changes it to the following:

scale up

Scale up always happens when the ideal size goes higher than the current resource request. But, then, we don't just apply the ideal size, but apply the ideal size * (1+buffer ratio). Meaning, we increase the resource request more than actually needed, which reduces the need of scaling up in the future.

scale down

We basically want to ignore too small scale down to reduce the frequency of restarts. Every time we calculate the previous ideal value by current resource req / (1+buffer ratio). And, if the current ideal value is much smaller than the previous ideal value, we apply scaling down.

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer: