Let’s cool down our Azure App Services
Sharing another story of our Azure Cost optimization. In this series we will talk about Azure App service cost optimization. How we can reduce the resources and take the full benefit of 'Pay as you go' model.
Scale in your Azure App Service
We can scale in Azure App service as per the usage. Two scaling options are available, Manual scale and Custom Autoscale.
In Manual scale, we get fixed number of instances as per the setting. App Service will always run with fixed number of instances.
Manual scaling setting in Azure App Service
Custom Autoscale gives us the liberty to increase or decrease the instances as per the usage. If load increases, it will automatically add a new instance to your App service and similarly if load decreases it will reduce the instances. Custom Autoscale settings help us in scaling Azure App services when the load increases/decreases.
In the below screenshot the app instance will increase if Average CPU utilization of all the instance increases by 70 and decreases if the value is below 50. Similarly we can add rules on different metrics like memory utilitzation,
Autoscaling setting in Azure App Service
Recommendation: Always go for Custom Autoscaling as instances will increase/decrease as per the load. Always have scale in rule so that instances reduces when the load decreases it. Having optimized app service instances will help to reduce the cost.
Scaling Azure App services on specific days or duration
With the above setting we will be able to handle user load but generally we keep certain number of instance so that performance of the app service is not impacted as we know the load of our application. We also know when this load decreases. Suppose we have an Enterprise application which will be used by the employees only, then most of the load will be on weekdays. Having minimum fixed number of instances will increase our cost and resources will unutilized on weekends. For example, if our services run on minimum 2 instances but we don’t need it 2 instances on weekend as it will be unutilized and we need to pay for it. Similarly, many e-commerce sites have sales and during sale they will have increased load. So, they can plan accordingly and increase the minimum no. of instances and once the sale is over the app service will automatically scale down.
In Azure App service we can do Auto scaling for specific days/duration also.
Now we will talk about how we can do it and how much cost we will be saving.
In Azure App service we can add multiple autoscaling rules. In the below screenshot we are reducing the minimum instance by 1 on weekend. And if the load increases, then it will autoscale and increase the count of instances so that users don’t face any performance issues.
We also have option to scale in/out for specific duration. Suppose during Christmas my application usage will be low so we can plan accordingly and set the instances count accordingly. Similarly, e-com sites can increase the instances beforehand if any sale is coming up as they know the load will be increased during that period. And once that time period is over the services will be back to normal.
Decreasing the instances by half on weekend with P1V2 app service plan will having to save the cost by $600 annually per app service.
In our subscription we had more than 20 app services. And by just optimizing the instances we are able to save $12000 annually.
We have furthur optimize the count of instance as per the region load. Suppose we have services deployed in multiple region and user load varies for each region as per the local timings. We have decrease the instances of the specific appservices when the load in the particular region is low. It will again help us to reduce the cost by 10-15% for the specific app service.