Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add auto-scaling calculation based by CPU load (#1722) #1726

Merged
merged 17 commits into from
Feb 19, 2020

Conversation

sre-bot
Copy link
Contributor

@sre-bot sre-bot commented Feb 19, 2020

cherry-pick #1722 to release-1.1


What problem does this PR solve?

#1651
Adding auto-scaling calculation algorithm based by CPU load.

This request adds the realization of auto-scaling calculation algorithm based by CPU load.
Currently, the auto-scaling is designed to support the cpu AverageUtilization in the following api spec:

  tikv:
    MetricsTimeDuration: "5m"
    metrics:
    - type: "Resource"
      resource:
        name: "cpu"
        target:
          type: "Utilization"
          averageUtilization: 80

notice
To use the auto-scaling by CPU load, the CPU requests in resources must be defined.

What is changed and how does it work?

I would take this spec as an example to explain how the calculation work.
The users create it to claim that the Operator could auto-scale tikv by CPU average load and the threshold value of average Utilization is 80%.

The Operator would query the CPU metrics from Prometheus (currently) to calculate the sum of CPU seconds for each tikv instances in the past 5mins every resync duration seconds.
If the sum of CPU seconds for total tikv instances in the past 5mins is 500 sec as cpuSecsTotal The cpu requests in resources is defined as 1 (1000mi) and current replicas of tikv is 3.

cpuRequestsRatio = 1000 / 1000 =1
durationSecs = 5mins = 300s
utilizationRatio = 80%
expectedCpuSecsTotal = cpuRequestsRatio * durationSeconds * currentReplicas * utilizationRatio = 1 * 300 * 3 * 0.8 = 720
recommendedReplicas = ceil(cpuSecsTotal * currentReplicas / expectedCpuSecsTotal) = 3

Related changes

  • Need to cherry-pick to the release branch

Does this PR introduce a user-facing change?:

NONE

@Yisaer Yisaer merged commit a7fb9b2 into pingcap:release-1.1 Feb 19, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/auto-scaling related to auto-scaling status/PTAL PR needs to be reviewed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants