Skip to main content

VM Scale Set

An Azure Virtual Machine Scale Set (VMSS) manages a group of load-balanced VMs as one resource. It can add or remove instances automatically based on demand or schedule, and replaces unhealthy instances.

VM Scale Set

A scale set is Azure's counterpart to an AWS Auto Scaling Group. You define the image, size, and configuration once, and the set creates identical instances from it. It supports two orchestration modes: Flexible, which is the recommended default and works with Availability Zones and mixed VM sizes, and Uniform, which uses a strict identical-instance model.

How Does Autoscale Decide When to Add Instances?

Autoscale rules read Azure Monitor metrics such as CPU, memory, or queue length, then apply thresholds, a cooldown, and minimum and maximum instance counts. You can also scale on a fixed schedule, for example adding capacity every weekday morning.

flowchart LR M["Azure Monitor
metrics"]:::tool -->|CPU over 70%| R["Autoscale rule"]:::app R -->|add instances| S["Scale set
10 to 80 VMs"]:::cloud S -->|serves| L["Load balancer"]:::person classDef tool fill:#326CE5,color:#FFFFFF classDef app fill:#EDE9FE,color:#1E293B classDef cloud fill:#D1FAE5,color:#1E293B classDef person fill:#FFEDD5,color:#1E293B

How Do You Create One?

Bash
az vmss create --resource-group mumbai-prod-rg \
--name order-matching-vmss --image Ubuntu2204 \
--instance-count 10 --vm-sku Standard_D4s_v5 \
--orchestration-mode Flexible --zones 1 2 3 \
--admin-username rahul
az monitor autoscale create --resource-group mumbai-prod-rg \
--resource order-matching-vmss --resource-type Microsoft.Compute/virtualMachineScaleSets \
--min-count 10 --max-count 80 --count 10

Why It Matters in Production

A delivery platform like Swiggy can scale its order-matching service up for the dinner rush and back down overnight, paying for capacity only when it is needed.

Common Mistake

Setting scale-out and scale-in thresholds too close together, such as out above 70 percent and in below 65 percent. The set flaps, adding and removing instances repeatedly, so leave a clear gap and a sensible cooldown.

Tip

Bake the application into a custom image so new instances are ready quickly during scale-out, and enable instance protection or graceful termination so scale-in does not cut in-flight requests.

Frequently Asked Questions

How is a scale set different from a group of separate VMs?

A scale set manages all instances as one resource with a shared model, built-in autoscale, and automatic replacement of unhealthy instances. Separate VMs need per-VM management and your own scaling logic.

Should I use Flexible or Uniform orchestration?

Use Flexible for new deployments, since it is the recommended mode and supports zones and mixed sizes. Use Uniform only if you depend on its specific behaviour.

What does a scale set need in front of it?

Usually a load balancer or Application Gateway, so traffic reaches whichever instances currently exist. Health probes or application health extensions let the set replace failed instances.

Found a mistake, an outdated step or a broken link?