Bounded autoscaling
Match capacity to demand
Autoscaling changes resource capacity in response to a policy. Horizontal scaling adds or removes instances; vertical scaling changes the size of an instance. A load balancer distributes traffic but does not inherently create instances. High availability (HA) concerns continuing service through failures, while deployment concerns changing the application version. A scaling group can help with all three, but each requires its own configuration and tests.
Consider the same fictional bookstore. A tested ready VM can sustainably handle 100 requests per second at the chosen latency objective. The teaching policy targets 80 requests per second per ready VM to reserve headroom. It allows at least two and at most six instances. This is a simple capacity model, not an actual provider policy or benchmark.
Calculate a bounded desired count
For nonnegative demand D and positive target capacity T, calculate raw count as ceil(D / T), then clamp it between the configured minimum and maximum. At D = 350 and T = 80, the raw count is 5, so the desired count is 5. At D = 30, the minimum of 2 wins. At D = 700, the raw count is 9 but the maximum limits the desired count to 6. Six ready instances provide 480 requests per second at the target, or 600 at the separately tested sustainable ceiling. Demand of 700 exceeds even that ceiling by 100.
Use consistent units: requests per second divided by requests per second per VM gives a VM count. Round up before applying bounds. A maximum count bounds that group's requested scale in this model; it does not cap total cloud costs, other resources or all temporary replacement capacity. Actual capacity may also be constrained by quotas, resource availability and placement.
Trace readiness and time delays
Desired count is a controller's goal, not the number of instances currently serving. A group can contain launching, ready, unhealthy or draining instances. New VMs need time to boot, initialize code, warm caches and pass health checks. Consider an observation at t=0 with 2 ready VMs and demand 350. The desired count rises to 5; three new VMs take exactly 120 seconds to become ready in this fixture. At t=60 there are still 2 ready VMs with a ceiling of 200 requests per second; shortfall is 150. At t=120 all five are ready, with a ceiling of 500 and no modeled shortfall.
Choose initialization and metric warmup periods based on measured behavior. A cooldown delays certain repeat scaling decisions; a stabilization window or hysteresis (different thresholds for increase and decrease) helps prevent rapid oscillations. These controls have different meanings across providers. Do not set identical thresholds and timings merely because their names look similar. For predictable peaks, consider scheduled or predictive scale-out where supported; verify readiness before the peak.
Select metrics and find the true bottleneck
CPU utilization is useful for CPU-bound services, but a queue worker may need a backlog or message age metric. A web service may use requests per target or a measured serving-capacity signal. Choose a signal that reflects load and responds predictably when capacity changes. A shared database's CPU saturation may not fall when more web VMs are added. Missing telemetry is not evidence that demand is zero.
Suppose 5 ready VMs can each process 100 requests per second, but the shared database supports only 300 equivalent requests per second. Model system capacity as min(5 * 100, 300) = 300. At demand 350, shortfall is 50 even though the VM tier alone has capacity. Adding a sixth VM does not increase this model's throughput. Investigate query latency, connection limits and dependency capacity, and use bounded admission control or queues as appropriate. Never generate uncontrolled retries or scale without an upper bound.
Compare autoscaling services
AWS EC2 Auto Scaling groups support dynamic target tracking with eligible metrics, including CPU or Application Load Balancer request count per target, and instance warmup settings. Azure Virtual Machine Scale Sets can use Azure Monitor autoscale rules with metric thresholds, cooldown and scale-in flapping protection. Google Compute Engine managed instance groups can use autoscaling based on CPU or supported load balancer serving capacity, with initialization and scale-in controls. These descriptions are intentionally scoped to the documented families; actual policies, metric aggregation, scale-in selection and limits differ.
Separate repair (replace an unhealthy VM), rollout (change its version) and autoscaling (change capacity). Spread across appropriate failure domains and plan capacity after losing one. With two zones each containing two ready VMs at 100 requests per second, loss of a zone leaves capacity 200, which is insufficient for demand 260. Increasing the group may improve resilience only if placement, dependencies and remaining-zone capacity support the design.
Estimate cost and validate a safe scale-in
Use hypothetical unit prices only: 2 VMs for 3 hours and 5 VMs for 2 hours at $0.10 per VM-hour cost (2*3 + 5*2)*0.10 = $1.60. A fixed 5-VM fleet for all 5 hours costs $2.50, a difference of $0.90 in VM charges alone. Real bills include disks, balancer charges, network transfer, logging, licenses and other resources. Budgets are not guaranteed hard caps.
Before scale-in, verify enough ready capacity remains, stop new traffic to retiring instances, drain or checkpoint work, and keep persistent state outside disposable instances. Monitor error rate, latency, queue age, desired/ready count, dependency saturation, costs and failed scaling events. Do not terminate an instance just because the CPU is low. A scale-in should preserve correctness, not merely reduce the invoice.
Practice: use a demand trace of 30, 350 and 700 requests per second with the bounds above. Explain why readiness lag and the shared database limit change the expected result. The next chapter examines managed relational databases, one common downstream dependency.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Bounded autoscaling — knowledge check
Choose the best answer for each offline scenario.
Demand is 350 rps and the target is 80 rps per VM, with bounds 2 to 6. What is the model desired count?
Desired count is 5, but only 2 VMs are ready at 100 rps each. What is the VM-tier ceiling?
Five ready VMs provide 500 rps in total; a shared database limits the system to 300 rps. What is the modeled ceiling?
Which control helps prevent repeated scale-in and scale-out near a threshold?
At a fictional $0.10 per VM-hour, 2 VMs for 3 hours and 5 for 2 hours cost how much for VM compute alone?