How to Scale Self-Hosted CI Runners to Zero When Idle
A self-hosted runner left running overnight bills and draws power for hours it does no work.
Static self-hosted fleets sit idle most of the day yet keep instances warm. Ephemeral runners that register per job and terminate after, with an autoscaler that scales the pool to zero when the queue is empty, remove that idle burn.
Steps
- Run runners in
--ephemeralmode so each takes one job then exits. - Drive scale from the queue with an autoscaler (for example actions-runner-controller on Kubernetes).
- Set the minimum replica count to zero so no runner stays warm when idle.
Register an ephemeral runner
Terminal
./config.sh --url https://github.com/my-org/my-repo \
--token "$RUNNER_TOKEN" \
--ephemeral \
--labels self-hosted,linux,x64
./run.shTradeoffs
- Scale-to-zero adds cold-start latency; the first queued job waits for a runner to boot.
- Ephemeral runners give a clean environment per job, which also reduces state-related flakiness.
Related guides
How to Run CI on Spot Instances to Cut Cost and WasteRun self-hosted CI runners on spare cloud capacity (spot or preemptible instances) to cut cost and use otherw…
How to Shut Down Idle CI ResourcesCap job runtime and tear down service containers and preview environments after CI, so no runner, database, o…