Maximizing ODCR Utilization with ASG reservations-then-balanced Strategy
ASG default AZ-balancing behavior overrides ODCR placement, causing unused reservations and redundant On-Demand spend. This article explains how the new reservations-then-balanced capacity distribution strategy resolves this by prioritizing ODCR utilization across AZs before balancing, eliminating the need for complex drain-and-refresh workarounds.
Problem Statement
Customers with On-Demand Capacity Reservations (ODCRs) distributed across multiple Availability Zones (AZs) experience sub-optimal reservation utilization when using Auto Scaling Groups. The ASG's default AZ-balancing behavior takes priority over ODCR placement, resulting in On-Demand instances being launched in AZs with insufficient ODCR capacity — even when reservations are available in other AZs.
This leads to:
- Wasted ODCR capacity (paying for reservations that go unused)
- Unnecessary On-Demand instance costs
- Complex operational workarounds that don't fully resolve the issue
Example Scenario Of Instance distribution
- Region: us-west-2 (3 AZs: us-west-2a, us-west-2b, us-west-2c)
- Instance Types: m6i.24xlarge, m7i.8xlarge, m7i.32xlarge
- Total ODCRs: 500 reserved instances across 20 capacity reservations
- ODCR Distribution: Unevenly spread across AZs
Terraform Configuration (Before Fix)
suspended_processes = ["AZRebalance"]
capacity_reservation_specification { capacity_reservation_preference = "capacity-reservations-first"}Why This Didn't Work
Despite suspending
AZRebalance and setting capacity-reservations-first :- When the ASG restored capacity, it still attempted to balance instance counts across AZs
- If an AZ lacked available ODCR capacity, the ASG launched On-Demand instances in that AZ
- ODCR instances in other AZs with available capacity were not utilized
- The ASG only pulled from a different AZ's ODCRs if there were zero On-Demand instances available in the target AZ
Root Cause
The
capacity-reservations-first preference operates within the AZ that the ASG's balancing logic selects. It does not override the AZ selection decision itself. With unevenly distributed ODCRs, this means the ASG may select an AZ with no available reservations, fall back to On-Demand, and leave reservations stranded in other AZs.Additional Constraint
Hardcoding specific ODCR IDs in Terraform was not viable because:
- It removes On-Demand fallback during demand spikes
- Many customers uses mixed instance types that are not reserved
Solution: reservations-then-balanced Distribution Strategy
Overview
AWS launched a new ASG feature:
reservations-then-balanced capacity distribution strategy. This strategy inverts the priority order:- First: Launch instances in AZs where ODCR capacity is available (regardless of current AZ balance)
- Then: Balance across AZs once all reservations are consumed
Combined with a Capacity Reservation Resource Group, this ensures the ASG is aware of all available ODCRs and prioritizes them before balancing.
Implementation
resource "aws_autoscaling_group" "example" { # ... existing ASG config ...
availability_zone_distribution { capacity_distribution_strategy = "reservations-then-balanced" }
capacity_reservation_specification { capacity_reservation_preference = "capacity-reservations-first" capacity_reservation_target { capacity_reservation_resource_group_arn = aws_resourcegroups_group.odcr_group.arn } }}Steps to Implement
- Create a Resource Group containing all relevant ODCRs for the ASG
- Update the ASG Terraform configuration to include:
-
availability_zone_distributionblock withreservations-then-balanced
-
capacity_reservation_targetpointing to the resource group ARN
- Remove the drain-and-refresh workaround — it is no longer needed
- Test by terminating On-Demand instances and verifying they are replaced with ODCR instances
What Changes
Indirect Savings: Operational Efficiency
- Eliminated drain-and-refresh workaround: Reduces operational complexity and engineer time
- Reduced instance refresh disruption: No need to drain 30% capacity before refreshing
- Faster scaling: No artificial capacity reduction step required
- Reduced risk: Eliminates the window where the ASG runs at 70% capacity during the refresh process
Benefits Summary
Benefit | Description |
|---|---|
Maximized ODCR Utilization | Reservations are consumed before On-Demand instances are launched |
Cost Optimization | Eliminates double-paying for capacity (unused ODCR + OD instance) |
Simplified Operations | Removes the need for complex drain/refresh/restore workflows |
Maintained Elasticity | On-Demand fallback still works when demand exceeds reserved capacity |
Mixed Instance Support | Works alongside ASGs that use both reserved and non-reserved instance types |
No Redistribution Required | Solves uneven ODCR distribution without needing to modify or reallocate reservations |
Key Takeaways
-
capacity-reservations-firstalone does not guarantee cross-AZ ODCR utilization
- Suspending
AZRebalanceprevents rebalancing of existing instances but does not change new instance placement logic
-
reservations-then-balancedis the correct solution when ODCRs are unevenly distributed across AZs
- Always combine with a Capacity Reservation Resource Group for the ASG to reference all available ODCRs
- This solution preserves On-Demand fallback — unlike hardcoding ODCR IDs
Related Resources
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article