0
0
GcpComparisonBeginner · 4 min read

Preemptible vs Spot VM GCP: Key Differences and Usage Guide

In Google Cloud Platform, 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.

FeaturePreemptible VMSpot VM
Maximum runtimeUp to 24 hoursNo fixed max runtime
Termination notice30 seconds30 seconds
AvailabilityLimited, depends on spare capacityHigher availability, uses excess capacity
PricingFixed discounted priceVariable discounted price, can change dynamically
Use casesBatch jobs, fault-tolerant workloadsFlexible workloads, long-running tasks with interruptions
Instance types supportedMost standard typesMost 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.

bash
gcloud compute instances create preemptible-vm-example \
  --zone=us-central1-a \
  --machine-type=e2-medium \
  --preemptible \
  --image-family=debian-11 \
  --image-project=debian-cloud
Output
Created [https://www.googleapis.com/compute/v1/projects/your-project/zones/us-central1-a/instances/preemptible-vm-example].
↔️

Spot VM Equivalent

This example shows how to create a Spot VM using the gcloud command-line tool.

bash
gcloud compute instances create spot-vm-example \
  --zone=us-central1-a \
  --machine-type=e2-medium \
  --spot \
  --image-family=debian-11 \
  --image-project=debian-cloud
Output
Created [https://www.googleapis.com/compute/v1/projects/your-project/zones/us-central1-a/instances/spot-vm-example].
🎯

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.

Key Takeaways

Preemptible VMs have a 24-hour max runtime and fixed discounted pricing.
Spot VMs offer no fixed max runtime and dynamic pricing with higher availability.
Both require your workload to handle sudden shutdowns with a 30-second notice.
Use Preemptible VMs for short, simple batch jobs and Spot VMs for longer, flexible tasks.
Spot VMs are a newer, more flexible option for cost savings on GCP.