Azure Web Apps Scaling
Scaling
Effectively managing Azure resources is essential to control the costs of a managed environment. It is challenging to know how powerful of a resource is required. In the past environments were scaled to the worst case or highest demand scenarios. Following the same design principle in the cloud will lead to idle resources and a painful monthly bill. Being able to scale effectively to meet fluctuating demand is an important part of harnessing the power of Azure.
In regards to App Services, Azure provides control for scaling up (increasing the power of each instance) and scaling out (increasing the number of instances).
Scaling Up
The App Services Pricing Tier is directly tied to increasing the CPU, disk size, memory and other features. The screenshot below provides an illustration of this:
Scaling Out
Basic, Standard and Premium plans allow a variable number of instances. Basic plans allow for the scaling to be manually configured while Standard and Premium allow for the instances to also be automatically scaled out and in depending certain pre-configured thresholds. Below illustrates how this can be manually specified:
Automated Scaling
Pricing Tier
In order to support scaling, the Web App needs to be in a service plan that supports automated scaling. In this example, the site is set to S1 Standard which will allow us to scale to up to 10 instances:
Scale By CPU
In many cases, automatic scaling can be achieved by simply setting up a scaly by CPU Percentage. In the following example, the web app will be set to have a minimum of 2 instances and a maximum of 6. The recommended setting range is 60 to 80 percent which indicates the average across the entire web role before a scale up or scale down is performed.
Also note the Notifications for Scale Actions. There are three options: the ability to email the administrators on the subscription, the ability to supply additional email addresses as well as the ability to send notifications to a webhook address.
Scale By Schedule and Performance Rules
For more control of scaling and/or the ability to alter the instances based on a known schedule, the Scale By can be set to schedule and performance rules. Below is an example of setting up scaling by CPU percentage or Http Queue Length:
Profiles
A collection of rules are grouped together under a profile allowing for greater control of scaling by allowing for a group of rules to be applied always, on a recurring schedule or for a fixed date range. For example, the following illustrates how the service can be kept ramped up over a special holiday weekend:
As an example of recurrence, the web app could be scaled out for the weekend on Friday:
And then on Tuesday the instance count could be set to a lower range as illustrated below:
Rules
Rules can be set based on a particular resource and metric. For example if a web app is used to process or feed a storage queue, the number of instances of the web app could be scaled depending on the queue length. The different types of resources is shown below:
To provide an example of the type of metrics that can be used to set up a rule, the following shows the web app server farms metrics:
How to Scale
In cases where scaling changes are a reaction to poor performance or high cost, it is important to determine where the bottleneck is in order to scale appropriately. Application Insights is very helpful here as well as some monitoring built into the Azure Portal. For example, in the monitoring section of a Web Apps is Metrics per instance (Apps). This can be used to determine CPU performance as indicated below:
The metrics can be broken down by running instance as well as gaining an understanding of the overall behavior across the server farm.
Summary
Azure Web Apps offer a rich mechanism for controlling the scale of a web app and managing scale is important to controlling cost as well as maintaining a well performing website. This article provides overview as well as some illustrations of how scaling could be used.
References
Scale up an app in Azure Scalability
Scale instance count manually or automatically
How to test scale out rules and notifications in Azure Web Apps
Autoscaling and App Service Environment