How does gitlab choose which identical runner to use?

Given a set of equally valid runners to use for a particular job, how does Gitlab choose which runner to use? Is there some way to override the default selection policy?

We have a few different machines which we use for CI and it seems that certain machines end up heavily loaded and others are barely used. Is it possible to get some basic round-robin policy or to select less-loaded machines or something similar?

As such GitLab doesn’t choose. All of the active runners check regularly (I don’t remember the interval, but it’s less than one minute by default) if there are jobs they should handle (by tags mostly), and if there is, they pick up the job.

If you’re not happy with how jobs are distributed among your runners, the most direct way to change allocation is to tags jobs, and configure runners to only run jobs with a specific tag (and/or untagged jobs).
A couple of less direct ways (I haven’t tried any of them, so I don’t know how well they work, I also don’t know how to configure it specifically):

  • configure the runners concurrency settings to make the more loaded ones run fewer jobs in parallel and/or make the less loaded ones run more jobs.
  • configure the frequency with which the runners check for new jobs. If the less loaded ones check more frequently than the more loaded ones, they should pick up more jobs.
3 Likes