0
0
Azurecloud~10 mins

Azure Spot VMs for cost savings - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Azure Spot VMs for cost savings
Request Spot VM
Check Available Capacity
Yes
Allocate Spot VM at Discounted Price
Run Workload
If Capacity Lost or Price Exceeds Max
Yes
Evict Spot VM
Option: Redeploy or Stop
Back to Request Spot VM
Wait or Use Regular VM
Back to Request Spot VM
The flow shows requesting a Spot VM, checking capacity and price, running workload, and handling eviction if capacity or price conditions change.
Execution Sample
Azure
Request Spot VM with max price $0.05
If capacity available and price <= max
  Allocate Spot VM
Run workload
If eviction signal received
  Evict VM
This code requests a Spot VM at a max price, runs workload if allocated, and evicts VM if Azure reclaims capacity.
Process Table
StepActionCapacity Available?Current Spot PriceMax PriceVM Allocated?Eviction SignalResult
1Request Spot VMYes$0.04$0.05NoNoCheck capacity and price
2Evaluate price and capacityYes$0.04$0.05YesNoAllocate Spot VM
3Run workloadYes$0.04$0.05YesNoWorkload running
4Price rises to $0.06Yes$0.06$0.05YesNoPrice exceeds max, eviction imminent
5Eviction signal receivedYes$0.06$0.05YesYesEvict Spot VM
6Redeploy or stopNo$0.06$0.05NoNoVM stopped or redeployed
7Request Spot VM againNo$0.06$0.05NoNoCapacity unavailable, wait or use regular VM
💡 Execution stops when capacity is unavailable or VM is evicted due to price or capacity changes.
Status Tracker
VariableStartAfter Step 1After Step 2After Step 3After Step 4After Step 5After Step 6After Step 7
Capacity AvailableUnknownYesYesYesYesYesNoNo
Current Spot PriceUnknown$0.04$0.04$0.04$0.06$0.06$0.06$0.06
Max Price$0.05$0.05$0.05$0.05$0.05$0.05$0.05$0.05
VM AllocatedNoNoYesYesYesYesNoNo
Eviction SignalNoNoNoNoNoYesNoNo
Key Moments - 3 Insights
Why is the Spot VM evicted even though capacity is still available?
Because the current Spot price rose above the max price set by the user (see Step 4 and Step 5 in execution_table), Azure evicts the VM to reclaim capacity.
What happens if capacity is not available when requesting a Spot VM?
The VM is not allocated (Step 7 in execution_table). The user can wait or choose a regular VM instead.
Does the VM run continuously once allocated?
No, the VM runs until Azure sends an eviction signal due to price or capacity changes (Step 3 to Step 5).
Visual Quiz - 3 Questions
Test your understanding
Look at the execution_table, at which step is the Spot VM first allocated?
AStep 1
BStep 2
CStep 3
DStep 4
💡 Hint
Check the 'VM Allocated?' column in execution_table rows.
According to variable_tracker, what is the 'Current Spot Price' after Step 4?
A$0.04
B$0.05
C$0.06
DUnknown
💡 Hint
Look at the 'Current Spot Price' row under 'After Step 4' in variable_tracker.
If the max price was increased to $0.07, what would happen at Step 4 in execution_table?
AVM would continue running as price is below max
BVM would be evicted due to price
CCapacity would become unavailable
DEviction signal would be ignored
💡 Hint
Compare 'Current Spot Price' and 'Max Price' columns in execution_table at Step 4.
Concept Snapshot
Azure Spot VMs let you use spare capacity at a discount.
You set a max price you are willing to pay.
VMs run until Azure reclaims capacity or price rises above max.
Evicted VMs stop or can be redeployed.
Best for interruptible, flexible workloads.
Full Transcript
Azure Spot VMs provide cost savings by using spare capacity at discounted prices. You request a Spot VM with a maximum price you agree to pay. If capacity is available and the current Spot price is at or below your max price, Azure allocates the Spot VM. Your workload runs on this VM. However, if Azure needs the capacity back or if the Spot price rises above your max price, Azure sends an eviction signal and the VM is stopped or redeployed. If capacity is unavailable when requesting, the VM is not allocated and you can wait or use a regular VM. This approach is ideal for workloads that can handle interruptions and want to save costs.