DEV Community

Cover image for Solved: Azure VM Scale Sets feel pointless, what am I getting wrong?
Darian Vance
Darian Vance

Posted on • Originally published at wp.me

Solved: Azure VM Scale Sets feel pointless, what am I getting wrong?

🚀 Executive Summary

TL;DR: Azure VM Scale Sets (VMSS) are designed for cloud-native, stateless workloads, treating instances as disposable “cattle” rather than unique “pets.” Their true power is unlocked by embracing uniform orchestration with automated deployments and leveraging robust, metric-driven autoscaling for dynamic resource management.

🎯 Key Takeaways

  • Adopt the “cattle” mentality for Uniform VMSS, where instances are identical, disposable clones, managed through replacement rather than individual patching or troubleshooting.
  • Implement automation, such as Custom Script Extensions, during VMSS provisioning to ensure all instances are uniformly configured and production-ready without manual intervention.
  • Utilize metric-driven autoscaling rules (e.g., based on CPU Percentage or queue length) to enable VMSS to automatically adjust instance counts, optimizing performance and cost efficiency based on real-time demand.
  • Differentiate between Uniform VMSS (for strictly identical, stateless instances) and Flexible VMSS (for hybrid workloads needing individual VM control and scaling) to select the appropriate orchestration mode.

Feeling that Azure Virtual Machine Scale Sets (VMSS) are just a complex version of Availability Sets? This guide clarifies their true purpose by exploring uniform orchestration, advanced autoscaling, and comparing them directly to help you build genuinely resilient and scalable cloud-native applications.

The Symptoms: Why Your VM Scale Set Feels Pointless

If you’ve found yourself thinking that Azure VM Scale Sets are an over-engineered solution to a simple problem, you’re not alone. This feeling often stems from a mismatch between the tool’s intended design and its application. The frustration typically manifests in a few common symptoms:

  • “It’s just an Availability Set with extra steps.” You’re creating a set of VMs, putting them behind a load balancer, but the management feels more rigid and complex than just using standalone VMs in an Availability Set.
  • “Scaling is slow and manual.” You find yourself manually adjusting the instance count, which feels no different from just creating or deleting a VM yourself. The “auto-scaling” promise seems to be more theoretical than practical.
  • “Managing individual instances is a nightmare.” Trying to SSH into a specific instance, apply a unique patch, or troubleshoot a single node feels cumbersome. The set treats all VMs as one entity, fighting your attempts to manage them individually.
  • “My stateful application doesn’t fit this model.” You have an application that relies on data stored on the local disk of a specific VM, and the idea of instances being terminated and replaced during a scale-in event is terrifying.

If these points resonate, the issue isn’t that VMSS is pointless; it’s that you might be using a tool designed for cloud-native, stateless workloads with a traditional, stateful mindset. Let’s fix that.

Solution 1: Embrace the Herd – Uniformity and Orchestration

The single most important mental shift required for VMSS is to stop thinking of your servers as “pets” and start treating them as “cattle.”

  • Pets: Unique, hand-raised, and lovingly cared for. If one gets sick, you nurse it back to health. This is a traditional on-prem server or a critical standalone Azure VM.
  • Cattle: Identical, numbered, and part of a herd. If one gets sick, you replace it with a new, healthy one. This is the VMSS philosophy.

VMSS in its default “Uniform Orchestration” mode is built exclusively for cattle. Every instance is intended to be an identical, disposable clone. You don’t patch them; you replace them with a new, patched image. You don’t troubleshoot a failing instance; you let the health probes detect it and the platform replaces it automatically.

Putting Uniformity into Practice

To achieve this “cattle” state, you rely on automation during deployment, not post-deployment configuration. The goal is that any new instance added to the set is immediately production-ready without manual intervention.

One of the most common ways to do this is with Custom Script Extensions. This extension runs a script on each VM as it’s provisioned, ensuring it’s configured identically every time.

Here’s an example using the Azure CLI to create a simple NGINX web server scale set. Notice how the configuration is “baked in” at creation time.

az vmss create \
  --resource-group myResourceGroup \
  --name myScaleSet \
  --image UbuntuLTS \
  --upgrade-policy-mode Automatic \
  --instance-count 2 \
  --admin-username azureuser \
  --generate-ssh-keys \
  --lb myScaleSetLoadBalancer

az vmss extension set \
  --publisher Microsoft.Azure.Extensions \
  --version 2.0 \
  --name CustomScript \
  --resource-group myResourceGroup \
  --vmss-name myScaleSet \
  --settings '{"fileUris":[],"commandToExecute":"sudo apt-get update && sudo apt-get install -y nginx && echo ''Hello from VMSS instance #''$(hostname) > /var/www/html/index.html"}'
Enter fullscreen mode Exit fullscreen mode

With this setup, every new instance, whether created initially or added during a scale-out event, will automatically install NGINX and serve a basic homepage. No manual SSH required.

Solution 2: Autoscale That Actually Works – Beyond the Basics

Manually changing the instance count of a VMSS misses the point entirely. The real power is in defining rules that allow the platform to manage the herd for you based on real-time demand.

Moving from Manual to Metric-Driven Scaling

Autoscaling shouldn’t be an afterthought; it’s the primary reason to use VMSS for stateless workloads. The most common metric is CPU Percentage, but you can scale based on memory, disk I/O, or even the length of an Azure Storage Queue (a powerful pattern for processing backlogs).

This Azure CLI command creates an autoscale rule for the VMSS we created earlier. It will add an instance when the average CPU load is over 75% and remove one when it drops below 25%.

# First, get the ID of the scale set
VMSS_ID=$(az vmss show --resource-group myResourceGroup --name myScaleSet --query id --output tsv)

# Now, create the autoscale setting
az monitor autoscale create \
  --resource-group myResourceGroup \
  --resource $VMSS_ID \
  --name myScaleSetAutoscaleSettings \
  --min-count 2 \
  --max-count 10 \
  --count 2

# Create the scale-out rule (add VMs)
az monitor autoscale rule create \
  --resource-group myResourceGroup \
  --autoscale-name myScaleSetAutoscaleSettings \
  --scale out 1 \
  --condition "Percentage CPU > 75 avg 5m"

# Create the scale-in rule (remove VMs)
az monitor autoscale rule create \
  --resource-group myResourceGroup \
  --autoscale-name myScaleSetAutoscaleSettings \
  --scale in 1 \
  --condition "Percentage CPU < 25 avg 5m"
Enter fullscreen mode Exit fullscreen mode

With this configuration, the scale set now breathes with your application's workload, ensuring performance during peaks and saving costs during lulls, all without human intervention.

Solution 3: Choosing the Right Tool for the Job

A major source of confusion is the evolution of VMSS itself. It's no longer a one-size-fits-all solution. Understanding the difference between Availability Sets, Uniform VMSS, and the newer Flexible VMSS is critical.

VMSS vs. Availability Sets: A Clear Comparison

An Availability Set is a simple grouping construct. It tells Azure, "Don't put these specific VMs on the same physical hardware." That's it. It provides high availability against hardware failure but offers no scaling or unified management.

A VMSS is an orchestration and scaling engine. It manages a pool of (usually) identical resources.

Here's how they stack up, including the two VMSS orchestration modes:

Feature Availability Set VMSS (Uniform) VMSS (Flexible)
Management Model Individual VMs ("Pets") Single resource managing a pool of identical instances ("Cattle") Single resource managing a pool of standard, individual VMs
Scaling Manual only (create/delete VMs) Automated (metric or schedule-based) and manual Automated and manual, with more granular control
Instance Homogeneity Not enforced. Can mix sizes, OS, etc. Strictly enforced. All instances share the same model (size, OS, config). Not enforced. Can mix VM sizes, spot/on-demand instances, and attach disks.
High Availability Spreads VMs across Fault Domains (FDs) and Update Domains (UDs). Spreads instances across FDs and UDs. Supports up to 1000 instances. Full control over FD placement. Can spread across Availability Zones.
Ideal Use Case Small number of stateful servers needing protection from hardware failure (e.g., domain controllers, database replicas). Large-scale, stateless workloads like web front-ends, batch processing, or container hosts where instances are disposable. Hybrid workloads. Managing a fleet of stateful VMs that also need some scaling capability (e.g., Quorum-based apps, open-source databases).

When is a VMSS the Wrong Choice?

VMSS is not a silver bullet. You should stick with standalone VMs in an Availability Set when:

  • Each server has a unique, critical role and cannot be easily replaced (e.g., Active Directory Domain Controllers).
  • You have a legacy stateful application that can't tolerate instances disappearing.
  • You only have 2-3 VMs and the overhead of setting up a scale set and autoscale rules provides no real benefit.

Furthermore, if your primary goal is to run a web application or microservices, you should strongly consider if IaaS is even the right layer of abstraction. Azure App Service (PaaS) or Azure Kubernetes Service (AKS) often provide a much more efficient and powerful platform for these workloads, handling the underlying scaling and infrastructure management for you.

Conclusion: Unlocking the Real Power of VMSS

Azure VM Scale Sets are far from pointless; they are a purpose-built tool for a specific architectural pattern. The feeling of pointlessness is a signal that the tool is being applied outside of its ideal use case. By shifting your mindset from "pets" to "cattle," mastering true, metric-driven autoscaling, and understanding the crucial differences between Uniform and Flexible orchestration, you can transform VMSS from a source of frustration into the resilient, cost-effective, and scalable backbone of your cloud applications.


Darian Vance

👉 Read the original article on TechResolve.blog


Support my work

If this article helped you, you can buy me a coffee:

👉 https://buymeacoffee.com/darianvance

Top comments (0)