Exercise - Configure a Virtual Machine Scale Set
Recall from the example scenario that your customers use one of the company's websites to manage and check the status of their shipments. This website is deployed to virtual machines and hosted on-premises.
You notice that users of the website have significant delays in response times when the overall CPU usage of the virtual machines exceeds 75 percent. You need the Virtual Machine Scale Set that hosts your web application to scale when the system hits this threshold. To save costs, you also want to scale back in when demand falls and the overall CPU usage across the scale set drops below 50 percent.
In this exercise, you configure autoscaling. Define scale rules that scale out and in again, according to the system's CPU usage.
Note
This exercise is optional. If you don't have an Azure account, you can read through the instructions to understand how to use the REST API to retrieve metrics.
If you want to complete this exercise, but you don't have an Azure subscription or prefer not to use your account, create a free account before you begin.
Create a scale-out rule
In the Azure portal, go to the page for the Virtual Machine Scale Set.
On the Virtual Machine Scale Set page, under Settings, select Scaling.
Select Custom autoscale. In the Default scale rule, ensure that the Scale mode is set to Scale based on a metric. Then select Add a rule.
On the Scale rule page, specify the following settings, then select Add:
Property Value Metric source Current resource (webServerScaleSet) Metric name Percentage CPU Operator Greater than Threshold 75 Duration 10 Time grain statistic Average Time aggregation Average Operation Increase count by Cool down (minutes) 5 Instance count 1
Create a scale-in rule
In the Default scale rule, select Add a rule.
On the Scale rule page, specify the following settings, and then select Add:
Property Value Metric source Current resource (webServerScaleSet) Metric name Percentage CPU Operator Less than Threshold 50 Duration 10 Time grain statistic Average Time aggregation Average Operation Decrease count by Cool down (minutes) 5 Instance count 1 Select Save.
The Default scale condition now contains two scale rules. One rule scales the number of instances out. Another rule scales the number of instances back in.