Skip to content
This repository has been archived by the owner on Mar 31, 2023. It is now read-only.

[Scalability] Enable Horizontal Pod Autoscaler (HPA) for Alcor deployment #679

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions kubernetes/services/vpc_manager_hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,26 @@ spec:
# if minReplicas is less than Deployment replicas value, it may cause scale down
minReplicas: 5
maxReplicas: 10
behavior:
scaleDown:
# Indicates that the stability window considers the expected state of the past (here within 300 sec) to prevent expansion and contraction
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 100
periodSeconds: 15
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does periodSeconds mean the time interval to check the percentage number?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does periodSeconds mean the time interval to check the percentage number?

Not really, periodSeconds: 15 above means it can reduce pods by up to 100% in 15 seconds.

# The autoscaler will choose the strategy that affects the minimum number of Pods
selectPolicy: Min
scaleUp:
stabilizationWindowSeconds: 0
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The value of stabilizationWindowSeconds differs in the ScaleUp and ScaleDown policies. Is it the best practice to set stabilizationWindowSeconds = 0? Does 0 meaning that the autoscaler will always respond to changes immediately?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The stabilization window is used to restrict the flapping of replicas when the metrics used for scaling keep fluctuating.
When the metrics indicate that the target should be scaled down the algorithm looks into previously computed desired states and uses the highest value from the specified interval.

For example,
here we set up
'scaleup:
stabilizationWindowSeconds: 0'

It should scale up the pods immediately if need.

and we set up
'scaledown:
stabilizationWindowSeconds: 300'

When current metrics indicate that we could scale down the pods, HPA will consider the state of past within 300 seconds to determine if we can scale down now.

policies:
- type: Percent
value: 100
periodSeconds: 15
- type: Pods
value: 4
periodSeconds: 15
selectPolicy: Max
metrics:
# Set the average usage rate of the cpu, scale up if it exceeds 50
- type: Resource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,4 +429,20 @@ public VpcWebJson deleteSubnetIdInVpcState(@PathVariable String projectid, @Path
return new VpcWebJson(inVpcState);

}

@RequestMapping(
method = GET,
value = {"/hpatest"})
@DurationStatistics
public double hpaTest() throws Exception {

double res = 0.001;

for (int i = 0; i < 100000; i ++) {
res += res * res;
}

return res;

}
}