| name: autoScalingDown |
| input: C: XEDI performance context; |
| output: none |
| //If the XEDI resource occupancy rate is low, it will not shrink, reducing the number of |
| //unnecessary shrinkages |
| if () { terminate scaling-down;} |
| //Get all the POD sets for XEDI |
| retrieve all pods of XEDI from K8S as collection<POD>; |
| for (POD pod: collection<POD>) { |
| retrieve pod. C; |
| //Avoid frequent POD scaling by cooling-off time |
| if (currentTime-pod. lastScalingTime < pod. C. ) { |
| enter next loop; |
| } |
| /∗Calculate POD expansion index∗/ |
| If (scalingStrategy == 0) { |
| //According to formulas (2) and (3), qi = 1, the response capacity expansion index based |
| //on mixed load rate was calculated |
| ; |
| } else { |
| //According to formulas (5)–(7), the predictive expansion index was calculated |
| ; |
| } |
| //Adjust pods with lower load rates |
| if (() { |
| //Reduce the number of copies of POD according to the flex index |
| pod. replicas = ∗I; |
| //Refresh the POD’s copy number configuration so that the POD’s shrinkage takes effect |
| refresh pod replication for K8S with XTuning. Scheduler; |
| } |
| //Stop shrinking when the resource utilization rate falls below the resource load rate |
| if () { terminate scaling-down;} |
| } |