How to Use Spot Instances for Self-Hosted Runners
Spot instances cost a fraction of on-demand, so idempotent CI jobs are a natural fit for interruptible capacity.
Run ephemeral runners on spot capacity. Because a reclaimed instance just drops the current job, keep jobs idempotent and let GitHub re-queue them.
Steps
- Provision spot instances in an autoscaling group as ephemeral runners.
- Register each runner with
--ephemeralso it exits after one job. - Handle reclamation by re-queuing the interrupted job on fresh capacity.
Register an ephemeral runner
Terminal
# On the spot instance, register a one-shot ephemeral runner
./config.sh --url https://github.com/my-org \
--token "$RUNNER_TOKEN" \
--ephemeral \
--labels spot,linux,x64
./run.sh # exits after one job; ASG replaces the instanceGotchas
- A reclaimed instance can kill a job mid-run; only use spot for retry-safe work.
- Spot prices fluctuate; set a max price and a fallback to on-demand for critical queues.
- Do not run deploys on spot capacity where an interruption could leave a half-done release.
Related guides
How to Use Ephemeral Runners to Control CostRegister self-hosted GitHub Actions runners as ephemeral so each machine runs exactly one job and is destroye…
How to Scale Runners to Zero to Cut Idle CostEliminate idle self-hosted runner cost by scaling the fleet to zero when no jobs are queued, using an autosca…