Generalized Logistics Function to optimize the number of GitHub action runners

Javad Shahkoohi
2 min readNov 8, 2021

It is challenging to find the right number of GitHub action runners when you want to run a job in parallel and the Generalized Logistics Function can help to find that.

As you know GitHub action provides a great feature for running the same job with different inputs in parallel, which is called the Matrix as your job’s strategy (find more information here). This matrix contains an array called include which includes all the initial data for every runner and you can access each of them directly by just pointing like matrix.specs.

When to use matrix?

There could be many use-cases that you want to use the matrix in your pipeline especially if you are using Cypress or Jest because you would have a lot of specs and you want to run all of your tests and it would take too much time. this means the deployment would get longer and longer day after a day because your developer would add more tests and each one also needed to be run. The matrix could be an anwaer for your need to distribute similar jobs among different runners.

There is a tiny point about inputs of the matrix you should take into consideration that is, some tools like Cypress manage the distribution of specs among all the parallel jobs on it is own(read here), while others like jest don't do that.

Why Generalised logistic function?

The Generalised logistic function is a mathematical solution developed for growth modeling such that you can expect a logarithmic behavior while you set a boundary for your problem.

How it would help us on the number of GitHub action runners?

As you know launching a new runner is expensive money-wise and time-wise then it is a trade-off and you should be careful about that. In our case, we don't want to allocate too many runners to a job and meanwhile don't want that job to take too long to finish, then what I will do is set an upper and lower boundary to my equation and customize the parameter based on my needs like follows:

  • A: the lower asymptote;
  • K: the upper asymptote
  • B: the growth rate;
  • Q: is related to the value Y(0)
  • C: constant value

Also, you can use the WolframAlpha service to plot your equation and see how it would act in different inputs.

In conclusion

Using a mathematical solution makes your development more sophisticated and more robust. Using the Generalised logistic function is a good answer if you want to make a balance between the number of parallel runners and the amount of time you want to spend to make your development process happy.

--

--