Sub topic 12
Static stability: pre-provisioned capacity for AZ loss
This chapter assumes you can read CloudFormation YAML. It also assumes you know how an Auto Scaling group (ASG) spreads instances across subnets and how an Application Load Balancer (ALB) health-checks targets.
The idea
A system is statically stable if it keeps working when a dependency fails, without making any changes. During an Availability Zone (AZ) impairment, the APIs you would use to recover, such as launching instances, are the ones most likely to be slow or throttled. Everyone else in the zone is also trying to recover at the same moment. If your plan says "the ASG will launch replacements", your recovery depends on the control plane.
The static alternative is to run enough capacity in the surviving AZs before anything fails. When a zone is lost, the load balancer stops routing to it and the remaining instances absorb the traffic. No scaling action is needed.
Sizing for AZ loss
Say your peak load needs the capacity of N_needed instances. With Z zones, you lose 1/Z of your fleet when one zone fails. To survive that, provision:
total = N_needed × Z / (Z − 1)
| Zones | Overprovision | Instances for a 4-instance peak | Per zone |
|---|---|---|---|
| 2 | 100% extra | 8 | 4 |
| 3 | 50% extra | 6 | 2 |
| 4 | 33% extra | 6 (rounded up from 5.3) | 1 or 2 |
More zones means less idle capacity. This is the main cost lever, and a later chapter covers it.
Configuring the ASG
Pin the minimum to the full overprovisioned count. Do not rely on a scaling policy to reach it.
Resources:
WebAsg:
Type: AWS::AutoScaling::AutoScalingGroup
Properties:
MinSize: "6"
MaxSize: "12"
DesiredCapacity: "6"
VPCZoneIdentifier:
- !Ref PrivateSubnetA
- !Ref PrivateSubnetB
- !Ref PrivateSubnetC
LaunchTemplate:
LaunchTemplateId: !Ref WebLaunchTemplate
Version: !GetAtt WebLaunchTemplate.LatestVersionNumber
TargetGroupARNs:
- !Ref WebTargetGroup
HealthCheckType: ELB
HealthCheckGracePeriod: 120Here the peak needs 4 instances and the group keeps 6, two per zone. Losing a zone leaves 4.
Other dependencies on the recovery path
Compute is only one part. Check each of these for hidden control-plane dependence:
- Cross-zone load balancing: If it is off, traffic splits evenly per zone. The surviving zones then receive an even share only if the load balancer nodes in the failed zone are removed from DNS. Enable it, or confirm the per-zone math.
- NAT gateways: Each AZ needs its own gateway and route table. Do not plan to create one during the event.
- Databases: RDS Multi-AZ failover is automatic. Promoting a read replica by hand is not.
- Scaling headroom: Account quotas, such as vCPU limits, must allow the full fleet in two zones. Otherwise a replacement launch fails exactly when you need it.
Common mistakes
- Sizing for average load instead of peak.
- Leaving subnet capacity too small, so the surviving subnets run out of IP addresses.
- Forgetting that a deployment during an incident can fail for the same reasons as scaling.
Exercise
A service needs 9 instances at peak and runs in 3 AZs. How many instances should the ASG keep to survive the loss of one AZ without launching anything, and how many per zone?
Show answer
9 × 3 / 2 = 13.5, so round up to 14 instances. Spread across 3 zones, that is 5, 5, and 4 (or 6 per zone, 18 total, to keep zones equal). If one 5-instance zone fails, the other two hold 9 or 10 instances, which covers the peak of 9.