Why it matters
Development and test VMs rarely need guaranteed capacity. Running them as Spot cuts their compute cost by more than half without changing their size.How nOps finds it
nOps reads on-demand Compute Engine vCPU and memory billing for each VM over the last 7 complete days. A VM is flagged when it was billed on all 7 days and at least 90% of its cost carries a non-production word (such as dev, test, staging or sandbox) in its instance or project name, with no production word. VMs named like a database (for example mysql, postgres, mongo, redis, kafka or db), VMs with more than 10% GPU or sole-tenant cost, VMs already on Spot and VMs where committed-use discounts cover more than half the cost are left out. The saving assumes Spot costs 40% of the on-demand list price (the low end of Google’s published 60-91% discount): it is the VM’s current cost after credits minus 40% of its list cost, scaled to a month, and must be at least $25 a month. Projects whose spend on the service is at least 90% paid by credits or promotions are left out.Before you start
The VM must tolerate being stopped at any time, and you need permission to stop and edit it.How to implement
- Confirm the VM can be stopped without warning (no local state that would be lost, no long-running job that cannot restart).
- Stop the VM, change its provisioning model to Spot with the termination action set to Stop (
gcloud compute instances set-scheduling VM_NAME --provisioning-model=SPOT --instance-termination-action=STOP --zone=ZONE), then start it. You can also recreate the VM as a Spot VM. - For a managed instance group, set the provisioning model to Spot in a new instance template and roll it out.
- Update Terraform so the next deployment does not change it back.
Risks and considerations
- Compute Engine can stop a Spot VM at any time with about 30 seconds’ notice, and may not have Spot capacity to restart it right away.
- This and an off-hours schedule are alternatives for the same VM. Apply one or the other, not both.
- To roll back, stop the VM and set its provisioning model back to standard.
FAQs
Why are VMs named like databases left out?
Why are VMs named like databases left out?
A database that is stopped without warning can lose writes or need recovery, so nOps does not recommend Spot for VMs whose names suggest one.