TExcelTAD
Home › Azure & Google Cloud for AWS Users › Scale Sets and Managed Instance Groups

Scale Sets and Managed Instance Groups

An Auto Scaling group keeps N identical instances running from a launch template, replaces unhealthy ones, spreads them across zones and changes N with load. Azure calls the same thing a Virtual Machine Scale Set; Google Cloud calls it a managed instance group (MIG).

On AWS this is… launch templates, Auto Scaling groups, health checks, target tracking and step scaling policies, from EC2 Auto Scaling.

Side by side

AWS Azure Google Cloud
Template launch template the scale set's own model (image, size, network), or a VM profile instance template (global or regional resource)
Group Auto Scaling group Virtual Machine Scale Set (Flexible orchestration mode recommended) managed instance group, zonal or regional
Spread across zones subnets in several AZs --zones 1 2 3 regional MIG distributes across zones
Health-based replacement ELB or EC2 health checks Application Health extension / load balancer probe + automatic instance repairs autohealing with a health check
Scaling policy target tracking, step, scheduled, predictive Autoscale settings (Azure Monitor): metric rules, schedules, predictive autoscaler: target CPU, load balancer utilisation, Cloud Monitoring metrics, schedules, predictive
Rolling update instance refresh upgrade policy (manual, automatic, rolling) rolling-action start-update with maxSurge / maxUnavailable

Two ways to decide N

The scaling logic differs in style:

  • Google Cloud's autoscaler (and AWS target tracking) works toward a target: "keep average CPU at 60%". It computes the size that would bring utilisation to the target.
  • Azure Autoscale is classically rule-based: "if average CPU > 70% over 10 minutes, add 2; if < 30%, remove 1", with a cool-down. (It also supports predictive autoscale.)
python · try it yourself
import math

def target_tracking(current, avg_cpu, target, lo, hi):
    want = math.ceil(current * avg_cpu / target)
    return max(lo, min(hi, want))

def azure_rules(current, avg_cpu, lo, hi):
    if avg_cpu > 70:
        return min(hi, current + 2)
    if avg_cpu < 30:
        return max(lo, current - 1)
    return current

demand = [35, 55, 82, 91, 76, 48, 22, 18]   # load as "average CPU % if we had 3 VMs"
gcp_n = az_n = 3
print("min   demand  GCP target 60%   Azure rules (+2 >70%, -1 <30%)")
for minute, cpu in enumerate(demand):
    load = cpu * 3              # total work; per-VM CPU falls as VMs are added
    gcp_cpu = load / gcp_n
    az_cpu = load / az_n
    gcp_n = target_tracking(gcp_n, gcp_cpu, 60, 2, 10)
    az_n = azure_rules(az_n, az_cpu, 2, 10)
    print(f"{minute * 5:>3}   {cpu:>5}%  {gcp_n:>8}          {az_n:>8}")
min   demand  GCP target 60%   Azure rules (+2 >70%, -1 <30%)
  0      35%         2                 3
  5      55%         3                 3
 10      82%         5                 5
 15      91%         5                 5
 20      76%         4                 5
 25      48%         3                 4
 30      22%         2                 3
 35      18%         2                 2

Target tracking jumps straight to the right size and comes back down as soon as load drops; rule-based scaling moves in fixed steps and lags. Real autoscalers add stabilisation windows, cool-downs and initialisation periods so they don't flap, which this model leaves out.

Creating the groups

Azure, sample session: a Flexible scale set across three zones with an autoscale profile.

bash
az vmss create -g rg-shop-prod-app -n vmss-web --orchestration-mode Flexible \
    --image Ubuntu2404 --vm-sku Standard_D2s_v5 --instance-count 3 --zones 1 2 3 \
    --vnet-name vnet-shop-prod --subnet snet-app --lb "" --admin-username azureuser --generate-ssh-keys

az monitor autoscale create -g rg-shop-prod-app --resource vmss-web \
    --resource-type Microsoft.Compute/virtualMachineScaleSets \
    --name as-vmss-web --min-count 2 --max-count 10 --count 3
az monitor autoscale rule create -g rg-shop-prod-app --autoscale-name as-vmss-web \
    --condition "Percentage CPU > 70 avg 10m" --scale out 2
az monitor autoscale rule create -g rg-shop-prod-app --autoscale-name as-vmss-web \
    --condition "Percentage CPU < 30 avg 10m" --scale in 1

Google Cloud, sample session: an instance template, a regional MIG with autohealing, and target-CPU autoscaling.

bash
gcloud compute instance-templates create web-v1 \
    --machine-type=e2-standard-2 --image-family=debian-12 --image-project=debian-cloud \
    --subnet=projects/shop-prod-4821/regions/europe-west1/subnetworks/app-ew1 --no-address \
    --service-account=web@shop-prod-4821.iam.gserviceaccount.com --scopes=cloud-platform \
    --metadata-from-file=startup-script=startup.sh

gcloud compute health-checks create http web-hc --port=8080 --request-path=/healthz

gcloud compute instance-groups managed create web-mig --region=europe-west1 \
    --template=web-v1 --size=3 --health-check=web-hc --initial-delay=120

gcloud compute instance-groups managed set-autoscaling web-mig --region=europe-west1 \
    --min-num-replicas=2 --max-num-replicas=10 --target-cpu-utilization=0.6 --cool-down-period=90

Rolling out a new template (sample):

bash
gcloud compute instance-templates create web-v2 ...
gcloud compute instance-groups managed rolling-action start-update web-mig --region=europe-west1 \
    --version=template=web-v2 --max-surge=3 --max-unavailable=0

--max-unavailable=0 with a surge gives the same behaviour as an ASG instance refresh with 100% minimum healthy: new instances come up before old ones go.

Test yourself

What is the Google Cloud equivalent of an AWS Auto Scaling group spread across three AZs?

  1. A zonal managed instance group
  2. A regional managed instance group
  3. An instance template
  4. An unmanaged instance group

Average CPU across 4 instances is 90% and the target is 60%. Roughly how many instances does a target-tracking autoscaler want?

  1. 4
  2. 5
  3. 6
  4. 9

Which Azure scale set orchestration mode is recommended for new deployments?

  1. Uniform
  2. Flexible
  3. Classic
  4. Spot