title | description | author | services | ms.service | ms.topic | ms.date | ms.author | ms.custom | ms.component |
---|---|---|---|---|---|---|---|---|---|
Autoscale Azure resources based on performance data or a schedule |
Create an autoscale setting for an app service plan using metric data and a schedule |
anirudhcavale |
azure-monitor |
azure-monitor |
tutorial |
12/11/2017 |
ancav |
mvc |
autoscale |
Autoscale settings enable you to add/remove instances of service based on preset conditions. These settings can be created through the portal. This method provides a browser-based user interface for creating and configuring an autoscale setting.
In this tutorial, you will
[!div class="checklist"]
- Create a Web App and App Service Plan
- Configure autoscale rules for scale-in and scale out based on the number of requests a Web App receives
- Trigger a scale-out action and watch the number of instances increase
- Trigger a scale-in action and watch the number of instances decrease
- Clean up your resources
If you don't have an Azure subscription, create a free account before you begin.
Log in to the Azure portal.
- Click the Create a resource option from the left-hand navigation pane.
- Search for and select the Web App item and click Create.
- Select an app name like MyTestScaleWebApp. Create a new resource group *myResourceGroup' and place it into the resource group of your choosing.
Within a few minutes, your resources should be provisioned. Use the Web App and corresponding App Service Plan in the remainder of this tutorial.
-
From the left-hand navigation pane, select the Monitor option. Once the page loads, select the Autoscale tab.
-
A list of the resources under your subscription that support autoscale are listed here. Identify the App Service Plan that was created earlier in the tutorial, and click on it.
-
On the autoscale setting, click the Enable Autoscale button.
The next few steps help you fill the autoscale screen to look like following picture:
- Provide a Name for the autoscale setting.
- In the default profile, ensure the Scale mode is set to 'Scale to a specific instance count'.
- Set the instance count to 1. This setting ensures that when no other profile is active, or in effect, the default profile returns the instance count to 1.
-
Click on the Add a scale condition link under the default profile.
-
Edit the Name of this profile to be 'Monday to Friday profile'.
-
Ensure the Scale mode is set to 'Scale based on a metric'.
-
For Instance limits set the Minimum as '1', the Maximum as '2' and the Default as '1'. This setting ensures that this profile does not autoscale the service plan to have less than 1 instance, or more than 2 instances. If the profile does not have sufficient data to make a decision, it uses the default number of instances (in this case 1).
-
For Schedule, select 'Repeat specific days'.
-
Set the profile to repeat Monday through Friday, from 09:00 PST to 18:00 PST. This setting ensures that this profile is only active and applicable 9AM to 6PM, Monday through Friday. During all other times, the 'Default' profile is the profile the autoscale setting uses.
-
In the 'Monday to Friday profile'.
-
Click the Add a rule link.
-
Set the Metric source to be 'other resource'. Set the Resource type as 'App Services' and the Resource as the Web App created earlier in this tutorial.
-
Set the Time aggregation as 'Total', the Metric name as 'Requests', and the Time grain statistic as 'Sum'.
-
Set the Operator as 'Greater than', the Threshold as '10' and the Duration as '5' minutes.
-
Select the Operation as 'Increase count by', the Instance count as '1', and the Cool down as '5' minutes.
-
Click the Add button.
This rule ensures that if your Web App receives more than 10 requests within 5 minutes or less, one additional instance is added to your App Service Plan to manage load.
We recommended you always to have a scale-in rule to accompany a scale-out rule. Having both ensures that your resources are not over provisioned. Over provisioning means you have more instances running than needed to handle the current load.
-
In the 'Monday to Friday profile'.
-
Click the Add a rule link.
-
Set the Metric source to be 'other resource'. Set the Resource type as 'App Services' and the Resource as the Web App created earlier in this tutorial.
-
Set the Time aggregation as 'Total', the Metric name as 'Requests', and the Time grain statistic as 'Average'.
-
Set the Operator as 'Less than', the Threshold as '5' and the Duration as '5' minutes.
-
Select the Operation as 'Decrease count by', the Instance count as '1', and the Cool down as '5' minutes.
-
Click the Add button.
-
Save the autoscale setting.
To trigger the scale-out condition in the autoscale setting just created, the Web App must have more than 10 requests in less than 5 minutes.
-
Open a browser window and navigate to the Web App created earlier in this tutorial. You can find the URL for your Web App in the Azure Portal by navigating to your Web App resource and clicking on the Browse button in the 'Overview' tab.
-
In quick succession, reload the page more than 10 times.
-
From the left-hand navigation pane, select the Monitor option. Once the page loads select the Autoscale tab.
-
From the list, select the App Service Plan used throughout this tutorial.
-
On the autoscale setting, click the Run history tab.
-
You see a chart reflecting the instance count of the App Service Plan over time.
-
In a few minutes, the instance count should rise from 1, to 2.
-
Under the chart, you see the activity log entries for each scale action taken by this autoscale setting.
The scale-in condition in the autoscale setting triggers if there are fewer than 5 requests to the Web App over a period of 10 minutes.
-
Ensure no requests are being sent to your Web App.
-
Load the Azure Portal.
-
From the left-hand navigation pane, select the Monitor option. Once the page loads select the Autoscale tab.
-
From the list, select the App Service Plan used throughout this tutorial.
-
On the autoscale setting, click the Run history tab.
-
You see a chart reflecting the instance count of the App Service Plan over time.
-
In a few minutes, the instance count should drop from 2, to 1. The process takes at least 100 minutes.
-
Under the chart, are the corresponding set of activity log entries for each scale action taken by this autoscale setting.
-
From the left-hand menu in the Azure portal, click All resources and then select the Web App created in this tutorial.
-
On your resource page, click Delete, confirm delete by typing yes in the text box, and then click Delete.
-
Then select the App Service Plan resource and click Delete.
-
Confirm delete by typing yes in the text box, and then click Delete.
In this tutorial, you
[!div class="checklist"]
- Created a Web App and App Service Plan
- Configured autoscale rules for scale-in and scale out based on the number of requests the Web App received
- Triggered a scale-out action and watched the number of instances increase
- Triggered a scale-in action and watched the number of instances decrease
- Cleaned up your resources
To learn more about autoscale settings, continue on to the autoscale overview.
[!div class="nextstepaction"] Archive your monitoring data