Skip to content

Spot instances

What are spot instances?

Spot instances are a purchasing option that allows you to take advantage of unused EC2 capacity in the AWS cloud.

This can result in significant cost savings, often up to 90% off the on-demand price.

However, spot instances are not guaranteed to be available at all times and can be terminated by AWS if the capacity is needed for on-demand instances.

Should I use spot pricing?

In practice, spot instance termination is extremely rare for instances that have been running for less than 1h, making it ideal for all CI workflows that last less than 1h, and which do not trigger critical side-effects, such as deployments jobs.

Also note that AWS will not bill you for any interrupted instance if it was running for less than 1h, which explains why interruptions for short-lived instances are very rare. AWS is clever enough to just reject the spot instance request if it knows that capacity is at a critical level.

See this AWS help page for more details.

Disable spot pricing

By default, RunsOn will always attempt to request an instance using spot pricing, and will default to using on-demand pricing if no instance can be started using spot pricing.

Therefore there is no real disadvantage to using spot pricing, except a slight delay (2-3s) if RunsOn has to fallback to on-demand pricing.

The only situation where you might want to disable spot pricing is:

  • for critical workflows that cannot be interrupted (e.g. deployment jobs).
  • if you require a specific instance type, which is often out of capacity, so as to avoid a few seconds delay at launch.

Disabling spot pricing can be done by using the spot=false label on your runs-on definition:

.github/workflows/my-workflow.yml
job: Test
runs-on: runs-on,runner=2cpu-linux-x64,spot=false

Spot allocation strategies

Supported allocation strategies on RunsOn include:

  • spot=price-capacity-optimized or spot=pco: This strategy balances between price and capacity to optimize cost while minimizing the risk of interruption.
  • spot=lowest-price or spot=lp: This strategy focuses on obtaining the lowest possible price, which may increase the risk of interruption.
  • spot=capacity-optimized or spot=co: This strategy prioritizes the allocation of instances from the pools with the most available capacity, reducing the likelihood of interruption.

For more details on each strategy, refer to the official AWS documentation on Spot Instance allocation strategies.