Scaling Azure App Services Automatically

Scaling out and in an app means that you increase or decrease the amount of instances that run your application.

For a web app, it means scaling the amount of web app instances up or down.

Let’s see how we can do that automatically.

Here I already have an app service web app.

 

In that app service, I can go to the scale out menu and scale out and up my app manually.

 

We will be choosing custom autoscale. This works based on scale conditions. A condition will scale in and out based on rules. Let us see by adding a rule.

 

Click on add a rule.

  • A scale rule works on metrics. The metrics could be CPU percentage of the web app, or anything else related to that like TCP packages or the HTTP queue length or even the amount of data that streams out of the web app

 

Let’s say for now we are choosing data out as the metric. You will see that it will show the data for the last few minutes.

 

This means that a scale action has been activated when the amount of data flowing out is greater than 70 bytes on an average for the last 10 minutes.

 

Say when that happens, we want to increase the number of instances by 5. Also, it will not execute the additional scale actions for this same rule for the next five minutes.

 

Add the rule.

 

Additionally, you can also configure the instance limits of this scale condition so that it will have a minimum of one instance and a maximum of a specific number.

 

It will have maximum of 6 instances. So, if something goes wrong, it will fall back on the default number which is 1.

  • You can also add specific instances as well, like adding an instance based on schedule. You can use this to scale-in to save costs on maybe the weekend.
  • However, we are not going to do that for now.

 

Finally save the settings.

  • Now when my users start using the app and scale actions are executed, you will see them in the run history.

 

You will see that in the run history here. Right now my app has not scaled up because the users are not using the app right now.

 

That is it for this demo. Go ahead and try this out yourself.