Northwest Cadence is currently building a reporting platform for TFS. As part of that platform, we’re leveraging Azure Websites in a fairly sophisticated manner. One of the key features we rely on is the ability to autoscale our websites based on schedule and load. Luckily, it’s also one of the simplest features to implement!
A bit of background on scaling web sites… The ability to scale websites is nothing new, and many frameworks and techniques support the automatic scaling of websites based on either a schedule or based on load. However, many of these require a substantial amount of configuration and an understanding of the underlying web server that’s serving the site. Not so with Azure, it’s basically a very quick UI wizard, or a simple Powershell command.
A bit of background on our use of websites… We use a single Azure Web Hosting Plan to host a group of independent Azure websites. (See http://azure.microsoft.com/en-us/documentation/articles/web-sites-web-hosting-plan-overview/ for more information.) That means we host multiple customer websites, each with their own independent Azure Website, in a single environment that scales together. The nice thing about this approach is that we’re able to scale up and down as needs arise, and the scaling impacts all of the sites. This reduces overall costs as well as simplifies autoscaling.
Now, on to scaling and autoscaling of Azure Websites!
You can scale your website using every tier except Free. Shared, Basic and Standard all support basic (aka manual) scaling. In Shared and Basic only manual is available, and in Basic and Standard you can also scale through the selection of instance size.
In the image below, the selections available for the Basic tier are shown. You can increase capacity either through the instance size (scaling up), through the instance count (scaling out), or a combination. (The Shared tier looks similar, but is missing the option for changing the instance size.) You scale out by simply dragging the slider bar to the right, increasing the number of instances.
The Standard tier is where the real action is. This tier lets you scale out automatically. The screenshot below shows the available settings.
With a Standard tier, you can manually scale out by simply dragging the bar across the instance count. This is very similar to the other tiers, except you can scale to far more instances. But with a Standard tier, you can set up autoscaling. This autoscaling is configured along two axis, schedule and metric. Currently the only metric available is CPU, however, that may change in the future. Since they sit on different axis, you can actually configure CPU scaling to be different depending on the schedule! Let’s take a look at the options.
Metric autoscaling allows scaling by CPU. To configure this, provide a lower and upper bound for the number of instances to scale to, and provide the upper and lower bounds for the CPU utilization that will drive the autoscaling behavior.
In the settings below, I’ve declared that the minimum number of instances should be two, and the maximum should be 6. I’ve also set the CPU lower and upper bounds to 60 and 80 percent, respectively. If the average CPU utilization for the current instances exceeds 80% and the number of current instances is less than 6, another instance will be brought online to share the load. If the average CPU utilization dips below 60%, then one of the instances will be shut down, concentrating the load onto fewer instances.
It’s all pretty straightforward, and Scale by Metric is a simple and powerful way to reduce costs, while still providing a great experience for users of the website.
If more control is required, then metric scaling can be combined with scheduled autoscaling to provide far more control. This allows different metric scaling to be set for different scheduled times!
With scheduled autoscaling, you select the scale based on day/night and weekday/weekend, as well as any custom dates and times you’d like to handle. In the image below, I’ve set up different scaling for both day/night, and weekday/weekend. And I haven’t added any custom dates.
Once saved, this results in a change to the configuration page. I can now configure scaling for my website for Week Day, Week Night, and Weekend. If I had any custom schedules set up, they would appear in the dropdown, as well.
Once a selection has been made, I set up the autoscaling, save it, and then select the next dropdown item to configure. Once all the configurations have been saved, the website will now scale according to those settings.
The settings for scheduled autoscaling can be set to automatically run a particular number of instances on a schedule, or to run different scale-by-metric settings.
Autoscaling Azure Websites is an important strategy for providing a good experience to website users, all while reducing overall costs. But it’s more than that. By dramatically simplifying the setup, configuration and maintenance of the website, it can allow for developers to move faster – focusing on the essentials of the website experience and not on setting up and configuring an autoscale framework.