Elasticity and Spot Capacity
The cloud's economic advantage comes from paying only for the capacity in use. This lesson explains autoscaling, serverless services and spot capacity, and how to choose between them for different workloads.
Learning outcomes
After completing this lesson, you will be able to:
- Describe dynamic, scheduled and predictive autoscaling.
- Explain when serverless is cheaper and when it is not.
- Explain how spot capacity works and which workloads suit it.
- Identify practices that make spot usage reliable.
- Choose between autoscaling, serverless and spot for a workload.
Autoscaling
Autoscaling adds capacity when demand rises and removes it when demand falls. Dynamic scaling reacts to a metric such as CPU utilization, request count per target or queue depth. Scheduled scaling changes capacity at known times, such as business hours. Predictive scaling, offered by some providers, forecasts demand from history and scales in advance.
Autoscaling saves money only when it scales in as well as out. Common mistakes are a minimum capacity set close to the peak, a scale-in policy so conservative that capacity rarely falls, and scaling on a metric that does not reflect load. The minimum should cover the quietest period with an appropriate margin, and the scaling metric should track the resource that actually limits the service.
Serverless
Serverless services, such as functions and serverless containers and databases, charge per request, per unit of execution time or per unit of capacity consumed, and scale to zero when idle. They suit spiky, intermittent and low-volume workloads, where a provisioned server would sit idle most of the time.
At high, steady volume, the per-request price can exceed the cost of provisioned capacity running at high utilization. The break-even point depends on the workload, so engineers should compare the two at the expected volume. Serverless costs are also sensitive to configuration: a function's memory setting determines its price per millisecond, and inefficient code that runs longer costs more on every invocation.
Spot capacity
Spot capacity (AWS Spot Instances, Azure Spot Virtual Machines, Google Cloud Spot VMs) is spare provider capacity sold at a deep discount, often a large fraction off the on-demand price. The provider can reclaim it when it needs the capacity back, with short notice: about two minutes on AWS and about 30 seconds on Azure and Google Cloud. Prices and availability vary by instance type, zone and time.
Spot suits work that is fault-tolerant: stateless web tiers behind a load balancer with an on-demand baseline, batch and data processing, CI/CD build agents, rendering, and training jobs that checkpoint their progress. It does not suit single-instance databases, stateful services without replication or jobs that cannot restart.
Using spot well
The following list describes practices that make spot reliable.
- Diversify across many instance types, sizes and zones, so that a shortage in one pool does not stop the workload.
- Handle interruption: drain connections, checkpoint work and let a scheduler restart tasks elsewhere.
- Mix capacity: keep an on-demand or committed baseline and add spot for the variable part.
- Use allocation strategies that choose pools with the most spare capacity, which reduces interruptions.
The following diagram compares the cost of the same work and lists what must change.

Suitable for spot?
Choosing an approach
The following comparison summarizes when each elastic approach fits best.
Choosing elasticity
A batch pipeline on spot
A nightly data pipeline runs on 40 on-demand instances for five hours at USD 0.50 per hour each. The jobs can restart from checkpoints. Spot prices for suitable instances average 65% below on-demand. What would moving to spot save, and what must change?
Today the pipeline costs 40 x 5 x 0.50 = USD 100 a night, about USD 3,000 a month. At 65% off, it would cost about USD 35 a night, saving about USD 1,950 a month before allowing for some rework after interruptions. The pipeline must use several instance types and zones, and the scheduler must restart interrupted tasks from their last checkpoint. A small on-demand fallback can protect the completion deadline.
Serverless or provisioned?
An internal API receives about 200,000 requests a day, mostly during business hours, and runs on two always-on instances costing USD 280 a month in total at 3% average utilization. A serverless equivalent is estimated at USD 25 a month. Another API receives 3,000 requests per second around the clock and runs efficiently on autoscaled instances. Which should use serverless?
The internal API is a strong serverless candidate: low, intermittent volume leaves provisioned instances almost idle. The high-volume API has steady, high utilization, where per-request pricing would likely cost more than efficiently used instances; it should stay on autoscaled capacity and may benefit from commitment discounts for its baseline.
Why should a spot-based workload use several instance types and zones?
Show answer
Spot capacity is reclaimed per capacity pool. Spreading across many pools reduces the chance that one shortage interrupts the whole workload and lets the scheduler replace interrupted capacity.
Exam Tips
Remember for the exam
- Autoscaling saves money only if it scales in; set minimums for the quiet period.
- Serverless suits spiky and low-volume load; steady high volume may be cheaper provisioned.
- Spot is reclaimed with about two minutes' notice on AWS and about 30 seconds on Azure and Google Cloud.
- Diversify spot across instance types and zones and handle interruptions.