Control loop for scaling agents in a cluster
A control loop for scaling cloud-based agents in a cluster includes a controller and a feedback signal. The controller may be a proportional-integral controller, or a proportional-integral-derivative controller. The controller may calculate a control variable based on a target number of idle agents for the cluster. The controller receives a target number of idle agents, as well as a current number of idle agents in a cluster. The controller computes the control variable based on the error between the target and current numbers of idle agents, and an integral of the error over time.
1. A computer-implemented method, the method comprising:
receiving, at a controller in a feedback loop, a target number of idle agents, wherein an idle agent is a computing resource in a cluster of cloud-based computing resources;
receiving, at the controller, a current number of idle agents in the cluster of cloud-based computing resources;
computing a control variable for the cluster of cloud-based computing resources based on the target number of idle agents and the current number of idle agents; and
submitting the control variable to a scheduler for managing the cluster of cloud-based computing resources, wherein the number of idle agents in the cluster of cloud-based computing resources scales based on the control variable,
wherein the controller is a proportional-integral-derivative controller, and the control variable is a sum of:
a proportional term that is proportional to an error, wherein the error is a difference between the target number of idle agents and the current number of idle agents;
an integral term proportional to a sum of past values of the error; and
a derivative term proportional to a change in the error.
2. The computer-implemented method of claim 1 , wherein the controller is configured to store past values of the error in a moving window, and the integral term is calculated based on the past values in the moving window.
3. The computer-implemented method of claim 2 , wherein the integral term is calculated from an exponentially weighted moving average of values in the moving window.
4. The computer-implemented method of claim 1 , further comprising:
comparing the integral term to a threshold value; and
if the integral term exceeds the threshold value, calculating the control variable as a sum of the proportional term and the threshold value.
5. The computer-implemented method of claim 1 , further comprising:
comparing the control variable to a threshold value; and
if the control variable exceeds the threshold value, submitting the threshold value to the scheduler.
6. The computer-implemented method of claim 1 , wherein the cluster is for performing tasks associated with a vehicle software build.
7. The computer-implemented method of claim 1 , wherein the cluster is for performing continuous integration build tasks.
8. A computer-implemented system, comprising:
one or more processing units; and
one or more non-transitory computer-readable media storing instructions, when executed by the one or more processing units, cause the one or more processing units to perform operations comprising:
receiving a target number of idle agents, wherein an idle agent is a computing resource in a cluster of cloud-based computing resources;
receiving a current number of idle agents in the cluster of cloud-based computing resources;
computing a control variable for the cluster of cloud-based computing resources based on the target number of idle agents and the current number of idle agents; and
submitting the control variable to a scheduler for managing the cluster of cloud-based computing resources, wherein the number of idle agents in the cluster of cloud-based computing resources scales based on the control variable,
wherein the control variable is a sum of:
a proportional term that is proportional to an error, wherein the error is a difference between the target number of idle agents and the current number of idle agents;
an integral term proportional to a sum of past values of the error; and
a derivative term proportional to a change in the error.
9. The computer-implemented system of claim 8 , wherein the operations further comprise storing past values of the error in a moving window, and the integral term is calculated based on the past values in the moving window.
10. The computer-implemented system of claim 8 , the operations further comprising:
comparing the integral term to a threshold value; and
if the integral term exceeds the threshold value, calculating the control variable as a sum of the proportional term and the threshold value.
11. The computer-implemented system of claim 10 , the operations further comprising:
comparing the control variable to a threshold value; and
if the control variable exceeds the threshold value, submitting the threshold value to the scheduler.
12. The computer-implemented system of claim 8 , wherein the cluster is for performing continuous integration build tasks.
13. One or more non-transitory, computer-readable media encoded with instructions that, when executed by one or more processing units, cause the one or more processing units to perform operations comprising:
receiving, at a controller in a feedback loop, a target number of idle agents, wherein an idle agent is a computing resource in a cluster of cloud-based computing resources;
receiving, at the controller, a current number of idle agents in the cluster of cloud-based computing resources;
computing a control variable for the cluster of cloud-based computing resources based on the target number of idle agents and the current number of idle agents; and
submitting the control variable to a scheduler for managing the cluster of cloud-based computing resources, wherein the number of idle agents in the cluster of cloud-based computing resources scales based on the control variable,
wherein the control variable is a sum of:
a proportional term that is proportional to an error, wherein the error is a difference between the target number of idle agents and the current number of idle agents;
an integral term proportional to a sum of past values of the error; and
a derivative term proportional to a change in the error.
14. The one or more non-transitory, computer-readable media of claim 13 , wherein the controller is configured to store past values of the error in a moving window, and the integral term is calculated based on the past values in the moving window.