Sub topic 9
Scaling with minRunners and maxRunners
This chapter explains how a runner scale set decides how many runner pods to run, and how minRunners and maxRunners bound that decision. It assumes you can read a Helm values file, use kubectl to inspect pods, and have already installed the controller and a scale set as shown in earlier chapters. You should also know that the listener is the pod that watches GitHub's job queue for one scale set.
What the two settings control
Every runner scale set has two numeric limits in its Helm values file:
minRunnersis the number of runner pods ARC keeps available even when no jobs are queued. The default is0.maxRunnersis the upper limit on runner pods for the scale set. When it is not set, ARC does not apply a cap other than what the cluster and GitHub allow.
The values file from the installation chapter used minRunners: 0 and maxRunners: 10:
githubConfigUrl: "https://github.com/<your-org>/<your-repo>"
githubConfigSecret: pre-defined-secret
minRunners: 0
maxRunners: 10
containerMode:
type: "dind"With these values the scale set is idle most of the time and never grows past ten pods. The settings do not give you a fixed pool. They give you a range, and ARC chooses a number inside it.
How ARC picks a number
The scale set does not poll the cluster for CPU load. It follows the job queue. The listener keeps a connection to GitHub and receives messages that describe the state of the queue for your scale set. Each message includes how many jobs are assigned and waiting, and how many runners are busy. The listener passes the desired count to the controller by updating the EphemeralRunnerSet resource, and the controller creates or deletes EphemeralRunner resources to match.
The target is roughly this:
desired runners = clamp(assigned jobs, minRunners, maxRunners)Here assigned jobs counts jobs that are running plus jobs that are queued and waiting for a runner from this scale set. clamp means the result is raised to minRunners if it is lower, and lowered to maxRunners if it is higher.
A worked scenario
Suppose the scale set is configured with minRunners: 2 and maxRunners: 5. The table shows what happens as jobs arrive and finish.
| Moment | Jobs running or queued | Desired runners | What you see in `arc-runners` |
|---|---|---|---|
| Idle | 0 | 2 | Two idle runner pods |
| A push triggers 1 job | 1 | 2 | One busy pod, one idle pod |
| A pull request triggers 4 more jobs | 5 | 5 | Five pods, all busy |
| Ten more jobs are queued | 15 | 5 | Five pods busy, ten jobs waiting |
| Queue drains | 0 | 2 | Pods finish and are deleted until two remain |
The fourth row is the important one. Once the cap is reached, extra jobs are not rejected. They stay queued on GitHub until a runner frees up. A low maxRunners therefore increases waiting time rather than causing failures.
Ephemeral runners change the arithmetic
Each runner pod is ephemeral: it takes one job and is then removed. This has two consequences for scaling.
First, scaling down is not a matter of stopping idle pods. A busy pod is never evicted to meet a lower target. It finishes its job and exits, and the controller does not replace it unless the desired count requires it.
Second, the pool is constantly turning over. When a pod finishes a job, a new pod appears only if the desired count says it should. With minRunners: 2, finishing a job in a quiet period leads to a fresh idle pod being created to keep the minimum. Each of those pods pulls an image and registers with GitHub, so startup time matters.
Choosing minRunners
minRunners trades money for latency.
- With
minRunners: 0, nothing runs while the queue is empty. The first job after an idle period must wait for the controller to create a pod, for the node to pull the image (and possibly for the cluster autoscaler to add a node), and for the runner to register. This can take from several seconds to a few minutes. - With
minRunners: 1or higher, a warm pod is already registered, so a job usually starts within a few seconds. You pay for that pod's requested CPU and memory all the time.
Typical choices:
| Situation | Suggested `minRunners` |
|---|---|
| Occasional nightly or manual jobs | 0 |
| A team that pushes throughout the working day | 1 to 3 |
| Pipelines where developers wait on checks | Enough to absorb a typical burst |
| Cost-sensitive cluster with spare node capacity | 0, and accept the cold start |
Warm runners also hide cluster-level delays. If your nodes scale from zero, minRunners: 0 combines the pod start delay with node provisioning delay. Keeping a small minimum can keep one node alive too.
Choosing maxRunners
maxRunners is a safety limit. Set it from the smaller of three constraints:
- Cluster capacity. Multiply the runner's resource requests by
maxRunnersand compare that with what the nodes can supply. If you allow 20 runners requesting 1 CPU and 2 GiB each, the scale set can ask for 20 CPUs and 40 GiB. - Cost. Each runner at the cap is a pod you are paying for, so the cap is also a spending limit.
- Downstream systems. Jobs may call package registries, databases, or deployment targets that cannot handle high concurrency.
If the cap exceeds what the cluster can schedule, pods stay in Pending. ARC considers them created, so the scale set looks correct while jobs still wait. Always check that maxRunners times your requests fits the cluster, or that a cluster autoscaler can add nodes.
Here is a values file that keeps a small warm pool and a larger cap, with requests set so capacity can be calculated:
githubConfigUrl: "https://github.com/<your-org>"
githubConfigSecret: pre-defined-secret
minRunners: 1
maxRunners: 20
template:
spec:
containers:
- name: runner
image: ghcr.io/actions/actions-runner:latest
command: ["/home/runner/run.sh"]
resources:
requests:
cpu: "1"
memory: 2Gi
limits:
memory: 4GiAt the cap, this scale set requests 20 CPUs and 40 GiB of memory. With dind mode, the sidecar container adds its own requests as well, so include it in your sums.
Changing the limits
The limits are Helm values, so you change them by upgrading the release:
helm upgrade arc-runner-set \
--namespace arc-runners \
-f values.yaml \
oci://ghcr.io/actions/actions-runner-controller-charts/gha-runner-scale-setRunning jobs are not interrupted by raising or lowering the limits. Pods created under the old settings finish their jobs normally.
Observing scaling
Watch runner pods while you trigger jobs:
kubectl get pods -n arc-runners --watchYou can also inspect the resources that carry the desired and current counts:
kubectl get autoscalingrunnersets -n arc-runners
kubectl get ephemeralrunnersets -n arc-runners
kubectl get ephemeralrunners -n arc-runnersThe listener log shows each message it receives and the count it requests, which is the quickest way to confirm that the scale set is reacting to the queue:
kubectl logs -n arc-systems -l actions.github.com/scale-set-name=arc-runner-set --tail=50Common errors
- Jobs wait although
maxRunnersis high. Runner pods are probablyPendingbecause nodes lack capacity. Runkubectl describe podon one and read the events. - Jobs wait although few runners exist. The workflow's
runs-onmay not match the installation name, so the job is never assigned to this scale set. The listener sees no jobs for it. - Costs stay high at night.
minRunnersis above zero, or pods are stuck and never complete. Check for pods older than your longest job. - Cold start is slow. The image is large or pulled from a distant registry. Use a smaller image, a registry close to the cluster, or a non-zero minimum.
- Several scale sets compete. Each scale set has its own limits. Their sum, not any single
maxRunners, must fit the cluster.
Exercise
A scale set has minRunners: 1 and maxRunners: 4. Eight jobs are queued at once and each takes ten minutes. How many runner pods exist while the jobs are being processed, and what happens to the jobs that cannot start immediately?
Show answer
Four pods exist, because the desired count is clamped to maxRunners. Four jobs run at once and the other four stay queued on GitHub. As each runner finishes a job, it exits, and the scale set creates a new pod so a queued job can run. All eight jobs complete in about twenty minutes. No job is rejected.
Exercise
Your team sets maxRunners: 30, with each runner requesting 2 CPUs. The cluster has 40 CPUs free and no cluster autoscaler. During a burst of 30 jobs, some jobs wait a long time even though ARC created 30 pods. Why, and how would you fix it?
Show answer
Thirty pods need 60 CPUs, but only 40 are free, so about ten pods stay Pending and their jobs cannot start. Either lower maxRunners to 20 or fewer, reduce the CPU request per runner, or add node capacity or a cluster autoscaler. You can confirm the cause with kubectl describe pod on a pending pod and looking for insufficient CPU events.