Algorithm for Autoscaling Proactively Instances - caprivm/thesis_msc GitHub Wiki

This section is purely theoretical and its objective is to explain what is the algorithm proposed to make a proactive scaling of resources. For this, a pseudocode is attached that is explained in detail. In addition, a flowchart is attached that visually implements the pseudocode. Before starting, it is important to consider that x[t] represents the general measurement of some variable at the current instant of time. On the other hand pd_x represents the prediction of these variables. Since the algorithm prioritizes proactive autoscaling over reactive, the possible combinations between current value and the predicted value on the nest thresholds are considered.

The contents of this page are:

Algorithm Detail

The algorithm begins with a data existence check to assess the current state of the system. If there is no data, you choose not to follow the procedure and retry until it exists. If data exists, the next step is to check the current state to assess whether an autoscaling decision should be made. Consequently, it is queried if any of the variables has exceeded the upper threshold, since it infers a possible saturation or congestion of the system. The procedure, in case the lower threshold is exceeded, is identical. If any of the variables exceeds the threshold, the value of the prediction at that instant is evaluated; If the prediction ensures that the threshold is also violated in the next instant, the autoscaling decision is made assuming that the system will saturate or make inefficient use of resources, as the case may be. If the prediction does not ensure the violation of the threshold, then it is decided to wait for the next instant of time and evaluate the state again. If in this new instant of time any of the variables violates the threshold, the decision to autoscale is made and it is assumed that the previous prediction was wrong. Otherwise, a new prediction value is considered; If this new prediction does not ensure a threshold violation, then the process returns to the first data verification task because it is assumed that the system will not saturate. In case the new prediction ensures the violation of the threshold, then the next moment of time is waited to evaluate the state of the system. If, at this new instant, there is a threshold violation, then the autoscaling decision is made, confirming the prediction. Otherwise, the process returns to the first task since the system was not saturated. It is important to mention that after any autoscaling decision, the procedure returns to the first data verification task.

On the other hand, if during the evaluation of the system state any of the established thresholds are not exceeded, it is assumed that the system maintains normal behavior or within the defined limits. Even with this behavior, the predicted value for some of the variables is considered. If this value infers a possible saturation in the next instant of time, the evaluation of the system state is resumed. Otherwise, the data availability monitoring process is maintained. The following is the pseudocode that implements what is described.

Pseudocode

The pseudocode of algorithm is:

start;
t = 0;
n_instances = 1;
variables = get(data);
while(true) {
    if(variables != NULL) {
        print "Data is available.";
        while(variables != NULL) {
            if(x[t] > threshold_x_max) {
                if(pd_x > threshold_x_max) {
                    funcion(autoscaling);
                    print "The system will saturate."; 
                    n_instances = n_instances + 1;
                }
                else {
                t = t + 1;
                if(x[t] > threshold_x_max) {
                    funcion(autoscaling);
                    print "Wrong prediction. The system will saturate."; 
                    n_instances = n_instances + 1;
                }
                else {
                    if(pd_x > threshold_x_max) {
                        t = t + 1;
                        if(x[t] > threshold_x_max) {
                            funcion(autoscaling);
                            print "Correct prediction. The system will saturate.";
                            n_instances = n_instances + 1;
                        }
                        else {
                            t = t + 1;
                            print "The system it was not saturate.";
                        }
                    }
                    else {
                        t = t + 1;
                        print "The system will not saturate.";
                    }
                }
            }
           }
           else {
           if(x[t] < threshold_x_min) {
                if(pd_x < threshold_x_min) {
                    if(n_instances == 1) {
                        print "Instances cannot be deleted. It is suggested to reduce the resources of the instance.";
                    } 
                    else {
                        funcion(autoscaling);
                        print "The system will be oversized."; 
                        n_instances = n_instances - 1;
                    }
                }
                else {
                    t = t + 1;
                    if(x[t] < threshold_x_min) {
                        if(n_instances == 1) {
                            print "Instances cannot be deleted. It is suggested to reduce the resources of the instance.";
                        }
                        else {
                            funcion(autoscaling);
                            print "The system will be oversized."; 
                            n_instances = n_instances - 1;
                        }
                    }
                    else {
                        if(pd_x < threshold_x_min) {
                            t = t + 1;
                            if(x[t] < threshold_x_min) {
                                if(n_instances == 1) {
                                    print "Instances cannot be deleted. It is suggested to reduce the resources of the instance.";
                                }
                                else {
                                    funcion(autoscaling);
                                    print "The system will be oversized."; 
                                    n_instances = n_instances - 1;
                                }
                            }
                            else {
                                t = t + 1;
                                print "The system not oversize."; 
                            }
                        }
                        else {
                            t = t + 1;
                            print "The system no will be oversized."; 
                        }
                    }
                }
           }
           else {
                if(pd_x > threshold_x_max || pd_x < threshold_x_min) {
                    t = t + 1;
                    print "The system may exceed any of the thresholds."; 
                }
                else {
                    t = t + 1;
                    print "Maintains normal behavior."; 
                }
            }
        }   
    }
    }
    else {
        print "No data was returned. Retrying get data.";
        t = t + 1;
    }
}

Flowchart

The flowchart that represents the pseudocode above is in the next figure.

NOTE: Please consider that the language of the figure is Spanish.

Autoscaling Flowchart

⚠️ **GitHub.com Fallback** ⚠️