Redigera

Dela via


Get started with autoscale in Azure

Autoscale allows you to automatically scale your applications or resources based on demand. Use Autoscale to provision enough resources to support the demand on your application without over provisioning and incurring unnecessary costs.

This article describes how to configure the autoscale settings for your resources in the Azure portal.

Azure autoscale supports many resource types. For more information about supported resources, see autoscale supported resources.

Discover the autoscale settings in your subscription

To discover the resources that you can autoscale, follow these steps.

  1. Open the Azure portal.

  2. Search for and select Azure Monitor using the search bar at the top of the page.

  3. Select Autoscale to view all the resources for which autoscale is applicable, along with their current autoscale status.

  4. Use the filter pane at the top to select resources a specific resource group, resource types, or a specific resource.

    A screenshot showing resources that can use autoscale and their statuses.

    The page shows the instance count and the autoscale status for each resource. Autoscale statuses are:

    • Not configured: Autoscale isn't set up yet for this resource.
    • Enabled: Autoscale is enabled for this resource.
    • Disabled: Autoscale is disabled for this resource.

    You can also reach the scaling page by selecting Scaling from the Settings menu for each resource.

    A screenshot showing a resource overview page with the scaling menu item.

Create your first autoscale setting

Note

In addition to the Autoscale instructions in this article, there's new, automatic scaling in Azure App Service. You'll find more on this capability in the automatic scaling article.

Follow the steps below to create your first autoscale setting.

  1. Open the Autoscale pane in Azure Monitor and select a resource that you want to scale. The following steps use an App Service plan associated with a web app. You can create your first ASP.NET web app in Azure in 5 minutes.

  2. The current instance count is 1. Select Custom autoscale.

  3. Enter a Name and Resource group or use the default.

  4. Select Scale based on a metric.

  5. Select Add a rule. to open a context pane on the right side.

    A screenshot showing the Configure tab of the Autoscale Settings page.

  6. The default rule scales your resource by one instance if the Percentage CPU metric is greater than 70 percent.

    Keep the default values and select Add.

  7. You've created your first scale-out rule. Best practice is to have at least one scale-in rule. To add another rule, select Add a rule.

  8. Set Operator to Less than.

  9. Set Metric threshold to trigger scale action to 20.

  10. Set Operation to Decrease count by.

  11. Select Add.

    A screenshot showing a scale rule.

    You have configured a scale setting that scales out and scales in based on CPU usage, but you're still limited to a maximum of one instance. Change the instance limits to allow for more instances.

  12. Under Instance limits set Maximum to 3

  13. Select Save.

    A screenshot showing the configure tab of the autoscale setting page with configured rules.

You have successfully created your first scale setting to autoscale your web app based on CPU usage. When CPU usage is greater than 70%, an additional instance is added, up to a maximum of 3 instances. When CPU usage is below 20%, an instance is removed up to a minimum of 1 instance. By default there will be 1 instance.

Scheduled scale conditions

The default scale condition defines the scale rules that are active when no other scale condition is in effect. You can add scale conditions that are active on a given date and time, or that recur on a weekly basis.

Scale based on a repeating schedule

Set your resource to scale to a single instance on a Sunday.

  1. Select Add a scale condition.

  2. Enter a description for the scale condition.

  3. Select Scale to a specific instance count. You can also scale based on metrics and thresholds that are specific to this scale condition.

  4. Enter 1 in the Instance count field.

  5. Select Repeat specific days.

  6. Select Sunday

  7. Set the Start time and End time for when the scale condition should be applied. Outside of this time range, the default scale condition applies.

  8. Select Save

A screenshot showing a scale condition with a repeating schedule.

You have now defined a scale condition that reduces the number of instances of your resource to 1 every Sunday.

Scale differently on specific dates

Set Autoscale to scale differently for specific dates, when you know that there will be an unusual level of demand for the service.

  1. Select Add a scale condition.

  2. Select Scale based on a metric.

  3. Select Add a rule to define your scale-out and scale-in rules. Set the rules to be same as the default condition.

  4. Set the Maximum instance limit to 10

  5. Set the Default instance limit to 3

  6. Select Specify start/end dates

  7. Enter the Start date and End date for when the scale condition should be applied.

  8. Select Save

A screenshot showing a scale condition for a specific date.

You have now defined a scale condition for a specific day. When CPU usage is greater than 70%, an additional instance is added, up to a maximum of 10 instances to handle anticipated load. When CPU usage is below 20%, an instance is removed up to a minimum of 1 instance. By default, autoscale scales to 3 instances when this scale condition becomes active.

Additional settings

View the history of your resource's scale events

Whenever your resource has any scaling event, it's logged in the activity log. You can view the history of the scale events in the Run history tab.

A screenshot showing the run history tab in autoscale settings.

View the scale settings for your resource

Autoscale is an Azure Resource Manager resource. Like other resources, you can see the resource definition in JSON format. To view the autoscale settings in JSON, select the JSON tab.

A screenshot showing the autoscale settings JSON tab.

You can make changes in JSON directly, if necessary. These changes will be reflected after you save them.

Predictive autoscale

Predictive autoscale uses machine learning to help manage and scale Azure Virtual Machine Scale Sets with cyclical workload patterns. It forecasts the overall CPU load to your virtual machine scale set, based on your historical CPU usage patterns. It predicts the overall CPU load by observing and learning from historical usage. This process ensures that scale-out occurs in time to meet the demand. For more information, see Predictive autoscale.

Scale-in policy

When scaling a Virtual machine Scale Set, the scale-in policy determines which virtual machines are selected for removal when a scale-in event occurs. The scale-in policy can be set to either Default, NewestVM, or OldestVM. For more information, see Use custom scale-in policies with Azure Virtual Machine Scale Sets.

A screenshot showing the scale-in policy setting.

Notify

You can configure notifications to be sent when a scale event occurs. Notifications can be sent to an email address or to a webhook. For more information, see Autoscale notifications.

Cool-down period effects

Autoscale uses a cool-down period. This period is the amount of time to wait after a scale operation before scaling again. The cool-down period allows the metrics to stabilize and avoids scaling more than once for the same condition. Cool-down applies to both scale-in and scale-out events. For example, if the cooldown is set to 10 minutes and Autoscale has just scaled-in, Autoscale won't attempt to scale again for another 10 minutes in either direction. For more information, see Autoscale evaluation steps.

Flapping

Flapping refers to a loop condition that causes a series of opposing scale events. Flapping happens when one scale event triggers an opposite scale event. For example, scaling in reduces the number of instances causing the CPU to rise in the remaining instances. This in turn triggers a scale-out event, which causes CPU usage to drop, repeating the process. For more information, see Flapping in Autoscale and Troubleshooting autoscale

Move autoscale to a different region

This section describes how to move Azure autoscale to another region under the same subscription and resource group. You can use REST API to move autoscale settings.

Prerequisites

  • Ensure that the subscription and resource group are available and the details in both the source and destination regions are identical.
  • Ensure that Azure autoscale is available in the Azure region you want to move to.

Move

Use REST API to create an autoscale setting in the new environment. The autoscale setting created in the destination region is a copy of the autoscale setting in the source region.

Diagnostic settings that were created in association with the autoscale setting in the source region can't be moved. You'll need to re-create diagnostic settings in the destination region, after the creation of autoscale settings is completed.

Learn more about moving resources across Azure regions

To learn more about moving resources between regions and disaster recovery in Azure, see Move resources to a new resource group or subscription.

Next steps