0
0
GCPcloud~10 mins

Preemptible and Spot VMs in GCP - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Preemptible and Spot VMs
User requests VM
Check VM type
Preemptible?
Create VM
Run VM
Google may stop VM anytime
VM stopped or deleted
User can restart or create new VM
When you request a VM as preemptible or spot, Google creates it but can stop it anytime to save resources. You can restart or create new VMs as needed.
Execution Sample
GCP
gcloud compute instances create example-vm \
  --zone=us-central1-a \
  --preemptible
This command creates a preemptible VM that runs until Google stops it, usually within 24 hours.
Process Table
StepActionVM StateGoogle's DecisionUser Impact
1User requests preemptible VMVM not createdCheck resource availabilityWaiting for VM creation
2Google creates VMVM runningVM runs normallyUser can use VM
3Google needs resourcesVM runningDecides to preempt VMVM will be stopped soon
4Google stops VMVM stoppedVM preemptedUser loses VM, must restart or create new
5User restarts or creates new VMVM runningVM runs normallyUser continues work
6VM runs up to 24 hoursVM runningVM may be preempted anytimeUser should save work often
7VM reaches max runtimeVM stoppedVM automatically stoppedUser must restart or create new
8EndVM stopped or runningNo further actionUser manages VM lifecycle
💡 VM stops when Google reclaims resources or max runtime reached; user must manage restarts.
Status Tracker
VariableStartAfter Step 2After Step 4After Step 5After Step 7Final
VM StateNot createdRunningStoppedRunningStoppedStopped or Running
Google DecisionNoneRun VMPreempt VMRun VMStop VMNo action
User ImpactWaitingUsing VMVM lostUsing VMMust restartManage VM
Key Moments - 3 Insights
Why does the VM stop even if I did not ask it to?
Google can stop preemptible or spot VMs anytime to free resources, as shown in execution_table step 4 where Google preempts the VM.
Can I keep a preemptible VM running forever?
No, preemptible VMs have a max runtime (usually 24 hours) after which Google stops them automatically (see step 7).
What should I do when my preemptible VM stops?
You need to restart or create a new VM to continue work, as shown in step 5 where the user restarts the VM.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table at step 4, what is the VM state?
ARunning
BStopped
CNot created
DRestarting
💡 Hint
Check the 'VM State' column in row for step 4 in execution_table.
At which step does the user restart or create a new VM?
AStep 3
BStep 7
CStep 5
DStep 2
💡 Hint
Look for 'User restarts or creates new VM' in the 'Action' column.
If Google never needed resources, what would happen to the VM state in the table?
AVM would keep running until max runtime
BVM would stop at step 4
CVM would never be created
DVM would restart automatically
💡 Hint
Refer to step 6 and 7 about VM running and max runtime.
Concept Snapshot
Preemptible and Spot VMs are cheaper VMs that Google can stop anytime.
You create them like normal VMs but expect interruptions.
Google stops them to free resources or after max runtime (~24h).
You must save work often and be ready to restart or create new VMs.
Ideal for batch jobs or fault-tolerant workloads.
Full Transcript
When you create a preemptible or spot VM on Google Cloud, the VM runs normally but can be stopped by Google at any time to free resources. This stopping is called preemption. The VM can run up to about 24 hours before Google stops it automatically. When the VM stops, you lose it and must restart or create a new one to continue your work. This makes preemptible and spot VMs cheaper but less reliable. They are good for tasks that can handle interruptions. The execution table shows the VM state changes from creation, running, preemption, stopping, and restarting. The variable tracker shows how VM state, Google's decisions, and user impact change step by step. Key moments clarify why VMs stop unexpectedly and what users should do. The quiz tests understanding of VM states and lifecycle steps. Remember, always save your work often and plan for VM interruptions when using preemptible or spot VMs.