Skip to content
Latchkey

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 --ephemeral so 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 instance

Gotchas

  • 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

Run this faster and cheaper on Latchkey managed runners. Start free →