DEV Community

Wakeup Flower
Wakeup Flower

Posted on

AWS Autoscaling termination policy

1️⃣ Balance Across Availability Zones (Highest Priority)

First, the Auto Scaling group ensures zone-level balance. If one Availability Zone has more instances than others, it will terminate from that zone—even before applying any other rules—then rebalance across zones. ([docs.aws.amazon.com][1])


2️⃣ Mixed Instances Groups: Spot vs On‑Demand Balancing

If you're using mixed instance types (Spot + On‑Demand), the system chooses which category to reduce based on your desired ratio. It then applies termination logic within the selected instance group and zone.


3️⃣ Outdated Configuration Check

Within the selected pool of instances (zone & market type):

  • For launch templates:
  1. Instances launched using launch configurations.
  2. Instances using a different launch template than the current one.
  3. Instances using the oldest version of the current launch template.
  • For launch configurations only:

    • Instances using the oldest launch configuration are terminated first. ([docs.aws.amazon.com][1])

4️⃣ Closest to Next Billing Hour

If multiple instances remain after the configuration check, the system terminates the instance that is closest to the next billing hour to minimize wasted cost (or chooses randomly if tied). ([docs.aws.amazon.com][1])


Optional Overrides

  • You can set custom termination policies (e.g., OldestInstance, NewestInstance, OldestLaunchTemplate, etc.), in which case Auto Scaling applies those rules in the order you specify, but zone balance always takes precedence. ([linkedin.com][2])

  • You can also implement custom policies via Lambda or enable instance scale-in protection to fine-tune which instances get terminated. ([docs.aws.amazon.com][3])


✅ Summary: Default Termination Priority (in Order)

  1. Balance zones — Terminate from the most populated Availability Zone.
  2. Balance Spot/On‑Demand (for mixed instance groups).
  3. Remove outdated configs — launch config or old template.
  4. Prevent cost waste — instance closest to next billing hour.

Top comments (0)