Optimizing Azure App Service for cost-efficiency

Ayla Naseer 100 Reputation points
2023-09-27T14:19:53.1366667+00:00

I am working on an Azure project to develop a new web application that is expected to experience significant traffic fluctuations. I am planning to use Azure App Service to host my application, and I am looking for best practices for using autoscaling to scale my App Service plan up and down automatically based on demand.

Please help with couple of questions here.
1- How do I configure autoscaling rules to ensure that my application is always available and performant, even during peak traffic periods?

2- Do you have any recommendations for third-party tools or services that can help me to optimize my Azure App Service autoscaling configuration?

and here's the last one
How to use autoscaling rules to scale my App Service plan in a warm-up mode to ensure that new instances are pre-warmed and ready to handle traffic when they are scaled in?

I would appreciate any advice or guidance that you can provide. Thank you!

Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,642 questions
0 comments No comments
{count} votes

Accepted answer
  1. Thomas Meads 1,586 Reputation points
    2023-09-27T16:26:10.57+00:00

    Hi,

    As called out App Service does support Auto scaling via rules and also via the new 'Automatic scaling' which is in preview. Firstly looking at auto scaling rules:

    Scaling via Rules

    To make sure that the app is scaled out to the required number of instances you need to analyses the traffic you will get. For instance if you know that at 1PM every day your site will double in usage then you can setup a rule to scale out at 12:30 to x instances. Alternatively if demand ramps up through a specific period then you would need to set it up to scale up based on CPU usage for example if the CPU hits 80% scale out 1 instance. These are the standard scale out conditions.

    The one condition this can not deal with is large spikes in demand as scaling out takes time (5 minutes if I recall correctly). As if your traffic doubles in 1 minute then the first instance will take all that load until the second instance can come online.

    More info https://learn.microsoft.com/en-us/azure/azure-monitor/autoscale/autoscale-get-started?toc=%2Fazure%2Fapp-service%2Ftoc.json

    Automatic Scaling

    Automatic scaling, which is currently in preview so not for production use yet, does look like it will handle more spiky traffic while also handling the other scenarios. This mode keeps a warmed instance of the site ready to go in the background so when it is needed this warmed instance will come into use and another instance will be warmed in the background.

    More info https://learn.microsoft.com/en-us/azure/app-service/manage-automatic-scaling?tabs=azure-portal

    Monitoring

    Azure monitor, App Insights, and Availability Tests are all the tools you should need to keep an eye on traffic, resource use, and request times.

    Pre-Warming

    Finally pre warming is a question that is answered nicely in this StackOverflow post: https://stackoverflow.com/questions/44552036/how-can-i-make-sure-a-new-autoscaled-azure-app-service-instance-is-warm-before-i

    1 person found this answer helpful.
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.