HOW TO CREATE A VIRTUAL MACHINE SCALE SET
Tags: virtualmachine, cybersecurity, scaling, vmss
Published: 2024-04-25 15:31:48

Creating a virtual machine scale set (VMSS) typically involves using a cloud platform's management interface or command-line tools. Below are general steps to create a VMSS in Azure, one of the popular cloud platforms, as an example:

**Navigate to the Azure Portal:** Log in to the Azure Portal (https://portal.azure.com).

**Create a Resource:** Click on the "Create a resource" button in the upper-left corner.

**Search for Virtual Machine Scale Set:** In the search bar, type "Virtual Machine Scale Set" and press Enter.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hpluwii27kdwythgg1or.png)



**Select Virtual Machine Scale Set:** Click on the "Virtual Machine Scale Set" option from the search results.

**Configure Basics:** Fill out the basic information such as subscription, resource group, VMSS name, region, etc.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7xy5tnft4exmw8rbmb2n.png)


**Choose Image:** Select the virtual machine image you want to use for your instances.

**Configure Instance Details:** Specify details like instance size, username, and password for the VM instances. Configure orchestration mode. In Azure VMSS, there are two types of orchestration modes:

1. Scale Set: In this mode, the scale set manager handles the scaling of VM instances within the scale set. It's the default mode and it's suitable for most scenarios.

2. VM: In this mode, Azure deploys each VM instance as an individual resource. Scaling is not handled by the scale set manager, and you need to manage the scaling manually or through other Azure services like Azure Automation.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kpe6rv6au495njn9jc90.png)

**Configure Autoscale:** Choose the Autoscale settings based on your requirements. This includes defining scaling rules based on metrics like CPU usage, memory, etc. It is important here to distinguish between Scaling Mode and Scale-In Policy Configuration.

Scaling Mode determines how the VMSS should scale. There are two scaling modes:

1. Manual Scaling: You manually adjust the number of VM instances in the scale set.

2. Automatic Scaling: Azure automatically adjusts the number of VM instances based on the defined scaling rules.

Scale-In Policy Configuration defines the criteria for choosing which VM instances to remove when scaling in. There are two scale-in policies:

1. Default: Azure chooses VM instances based on their instance IDs.

2. Newest VM Instance: Azure removes the newest VM instances first.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jzpuepxlj5t17qq5r7t6.png)


**Configure Networking:** Define the networking settings including virtual network, subnet, public IP address (if needed), and network security group.

**Configure Load balancing:** In Microsoft Azure, load balancing for Virtual Machine Scale Sets (VMSS) is typically managed through Azure Load Balancer or Azure Application Gateway, both of which offer different capabilities. 
A load balancer distributes incoming network traffic across multiple VM instances in a VMSS to ensure high availability and reliability of applications. 
You need to enable a load balancer when you want to distribute incoming traffic among multiple VM instances. This is typically done when:

1. You have multiple instances of your application running to handle the incoming traffic efficiently.

2. You want to ensure high availability and fault tolerance by distributing traffic across multiple instances.

3. You need to scale your application horizontally to handle increased traffic loads.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/qphlq01til01s64yxukv.png)

**Review + Create:** Review all the configurations you've made, and click on the "Create" button to deploy the VMSS.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/x3a9e6r01t083rkuifz7.png)

**Monitor and Manage:** Once your VMSS instances are deployed, you can monitor their performance, manage scaling, and make any necessary updates or changes through the Azure Portal or Azure CLI. In the example below, 4 virtual machine scale sets were created. 


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r0s4ao65c829thbb2amg.png)

By following these steps, you can create multiple Virtual Machine Scale Sets in Azure to support your applications with scalable and highly available infrastructure. Good luck!