Preemptible vs Spot VM GCP: Key Differences and Usage Guide
Preemptible VMs are short-lived instances that can be terminated at any time before 24 hours, offering lower prices but less availability. Spot VMs are similar but provide more flexible termination policies and can run longer, making them suitable for fault-tolerant workloads with cost savings.Quick Comparison
This table summarizes the main differences between Preemptible and Spot VMs in GCP.
| Feature | Preemptible VM | Spot VM |
|---|---|---|
| Maximum runtime | Up to 24 hours | No fixed max runtime |
| Termination notice | 30 seconds | 30 seconds |
| Availability | Limited, depends on spare capacity | Higher availability, uses excess capacity |
| Pricing | Fixed discounted price | Variable discounted price, can change dynamically |
| Use cases | Batch jobs, fault-tolerant workloads | Flexible workloads, long-running tasks with interruptions |
| Instance types supported | Most standard types | Most standard types, newer feature |
Key Differences
Preemptible VMs are designed to be low-cost, short-lived instances that Google can stop at any time, but they always have a maximum lifespan of 24 hours. They offer a fixed discount compared to regular VMs and are ideal for batch processing or jobs that can restart easily.
Spot VMs are a newer option that also use excess capacity but do not have a strict 24-hour limit. Their pricing can vary dynamically based on supply and demand, and they provide the same 30-second termination notice. Spot VMs offer more flexibility and higher availability, making them better for workloads that can handle interruptions but need longer runtimes.
Both types are cheaper than regular VMs but require your applications to handle sudden shutdowns. Spot VMs are generally recommended for newer projects needing cost savings with more runtime flexibility, while Preemptible VMs remain useful for simple, short batch jobs.
Preemptible VM Example
This example shows how to create a Preemptible VM using the gcloud command-line tool.
gcloud compute instances create preemptible-vm-example \ --zone=us-central1-a \ --machine-type=e2-medium \ --preemptible \ --image-family=debian-11 \ --image-project=debian-cloud
Spot VM Equivalent
This example shows how to create a Spot VM using the gcloud command-line tool.
gcloud compute instances create spot-vm-example \ --zone=us-central1-a \ --machine-type=e2-medium \ --spot \ --image-family=debian-11 \ --image-project=debian-cloud
When to Use Which
Choose Preemptible VMs when you have short, batch jobs or fault-tolerant workloads that can restart easily and you want a simple, fixed discount.
Choose Spot VMs when you need longer runtimes, higher availability, and can handle dynamic pricing and interruptions for cost savings on flexible workloads.