Algorithm 1 Latency-based Horizontal Pod Autoscaling with Custom Metrics API |
Require:: Target latency value
-
1:
ActivePods: Set of currently active pods
-
2:
MinPods: Minimum number of pods
-
3:
ScalingThreshold: Threshold for scaling (e.g., percentage increase in latency)
-
4:
CustomMetrics: Custom Metrics API for collecting and measuring latency values
-
5:
-
6:
Initialize Custom Metrics API: CustomMetrics.initialize()
-
7:
MaxPods = None
-
8:
while True:
-
9:
-
10:
for pod in ActivePods:
-
11:
-
12:
-
13:
end for
-
14:
-
15:
-
16:
if MaxPods is None:
-
17:
MaxPods = determineMaxPods()
-
18:
-
19:
call AggregateLatenciesAcrossNodes()
-
20:
call CalculateSeparateLatencyThresholdsForEachNodeOrPod()
-
21:
call TakeIntoAccountDifferencesInCapabilitiesAcrossNodes()
-
22:
if and len(ActivePods) < MaxPods:
-
23:
-
24:
-
25:
elif and len(ActivePods) > MinPods:
-
26:
-
27:
-
28:
else:
-
29:
-
30:
end if
-
31:
if :
-
32:
call ScaleUp(P)
-
33:
elif :
-
34:
call ScaleDown()
-
35:
end if
-
36:
call wait()
|