Azure app service plan obtain actual ACU usage - azure

I have an EP1 app service plan that is hosting a function app.
The plan has 210ACU per month.
How do I find out how many of those I'm using?
(What happens if I run out?)

Azure Compute Unit (ACU) provides a way of comparing compute (CPU) performance across Azure SKUs.
Here you should analyze the CPU Usage and Memory Usage by going to the Diagnose and Solve problems > Availability and Performance:
In this case, you can Scale Up and Scale Out the App Service for meeting the demands during peak hours or you can increase the number of instances count.
Please check this SO Thread1 where I explained about how Scale Up and Scale Out methodology works.
Also, you can create the alerts using Azure Monitor for the app service on different quota exceeds like CPU usage, Memory Consumption, Request Failures, etc.

Related

Understanding Azure Functions with App Service Plan

While creating an Azure Function. It provides an option to create an App Service Plan.
Let's say we select P2V2 which has 7GB Ram and 2 Cores. Here are the questions:
Let's say when the function is triggered, and each invocation consumes 1GB Ram. Does it mean that the same instance at maximum can concurrently run ~6 (leaving aside 1GB for OS let's say). Where all the 6 concurrent triggered functions re-use the same cores?
When does the App Service plan decide to scale out to multiple instances?
Yes, probably. As stated in Azure Functions hosting options - Service limits the number of Function apps per plan is unbounded, but:
The actual number of function apps that you can host depends on the activity of the apps, the size of the machine instances, and the corresponding resource utilization.
By default, an App Service Plan doesn't scale. In the same article I linked to before, it states that for a Dedicated Plan you can use Manual scaling or Autoscale. For autoscale, you control the rules.
For more information, see the documentation Juunas linked to in this comment.
Best practices for Autoscale

Azure App Service Plan Overview shows different CPU usage than Application Insights Live Metrics

I have an Azure App Service Plan (tier P1V2) that contains a number of App Services. Each of the App Services is attached to an Application Insights instance.
The App Service Plan Overview shows a CPU usage summary of 100%, but Application Insights Live Metrics shows a very low CPU usage.
Is there an explanation for the values being very different or am I doing something wrong?
Here are images showing what I am seeing. (Note that the first is taken over roughly 1 hour and the second one is over 60-seconds, but the figures have been the same throughout the time I have been looking at this.)
About the difference between the two charts:
What is shown in 'Live Metrics Stream' is the CPU usage of w3wp process, whereas what is shown in App Service Plan level is the total Machine CPU usage.
For the 100% CPU usage in Application Insight. You can use Diagnostics and Solve Problem to see what going wrong.
You also can have a look at this issue to find out what process is occupying CPU kindly look for total_cpu_time/user_cpu_time/privileged_cpu_time..

How to Calulate ACU required by my Web APP

I have a Web APP in Azure PAAS service App Service. App service plan uses a unit named as "ACU".
Is there any way by which i can calculate the number of ACU required by my web app.
As i have to do billing calculations so i need to prove that instance size chosen is based on some logical calulation.
Q. What is the Azure Compute Unit (ACU)?
A. The concept of the Azure Compute Unit (ACU) provides a way of comparing compute (CPU) performance across Azure SKUs.
The Azure Compute Unit (ACU) is used to help understand the
relative compute performance between different Azure series and size
VMs. It is based on the A0 (extra small) having a value of 50. A VM
with an ACU of 100 has twice the compute of a VM with an ACU of 50. A
VM with an ACU of 200 would be twice that of a VM with an ACU of 100
and so on.
So you should analyse the CPU Usage and Memory Usage.
For seeing that, you can go to your app service-->Diagnose and solve problems-->Availability and Performance.
The most important thing is NOT just considering ACUs for scalability and cost.
So you can Scale Up and Scale Out your App Service for meeting the demands during peak use and getting the final cost.
Vertical Scaling: For scaling up, since you don't initially know what kind of VM should suffice, you can start with a basic or intermediate one (not a very powerful one). General purpose Type VMs (50-210 ACUs) suffice in most cases. Link: https://learn.microsoft.com/en-us/azure/app-service/manage-scale-up
Horizontal scaling: It's good practice to also scale out your App service plan. You can autoscale and set up autoscaling rules or go the manual route.
Link: https://learn.microsoft.com/en-us/azure/azure-monitor/autoscale/autoscale-get-started
Next you should monitor your CPU Usage and Memory Usage as suggested by Doris.
Additionally you can also go to Run History and see your usage:
Based on your findings you can tweak the number and kind of VMs you need.

How long does it take for an Azure App Service instance to be available after a scale out?

Context: I am designing the auto-scaling (scale out) configuration for my .NET Framework 4.7 web app hosted on a Microsoft Azure App Service. I am using the P3V2 pricing tier. The application is CPU-bound. The app's 30 day CPU average is 30% usage while running on 2 instances, according to the stats indicated in the App Service plan. We occasionally have traffic spikes which will overwhelm the 2 instances: I want to implement auto-scaling.
I want to take into account the App Service Provisioning + App Startup Time when designing the metrics thresholds that decide when my app service scales out. I need to make my thresholds low enough to give Azure time to spin up a new app service instance but not so low that I am paying unnecessarily for processing power that's not needed. Budget is a significant factor.
Question: How long does it take for an Azure App Service instance to be available after a scale out? In other words, how long does it take for an Azure App Service to scale out?
P.S. I recognize that there is a lot more to scaling in/out that I am not addressing here. I'm trying my best to be succinct. :)
Generally, not long at all. By that I mean typically under one minute, but the time will vary depending on several factors, such as application size, time of day, region of deployment.
You could scale out manually and inspect the run history logs on the scale out tab.
FYI you can also use Azure Monitor to create auto-scale policies, in case this is of any use to you.

Azure App Service - CPU Percentage of instance vs plan

I am running a load test against my Azure Web App P3 pricing tier. We have the following auto scale out strategy -
Min Instance 5 and Max instance 20, Increase by 1 Instance if CPU Percentage (Max) goes more than 85%, Decrease by 1 Instance if CPU Percentage Average goes below than 50%
Right now, it is running with 5 instances. If I go to Applications Insights, 'Live Metrics Stream' pane of all available instances, it shows that CPU usage is around 75% (average) in all the 5 instances. In fact, some of the instances are nearing 85%.
Whereas, if I turn to CPU usage chart on the App Service Plan level (I have only one app running under the plan), it shows only 20%.
How do we reconcile these two conflicting stats?
What is shown in 'Live Metrics Stream' is the CPU usage of w3wp process, whereas what is shown in App Service Plan level is the total Machine CPU usage. The former is not normalized for take into account the number of logical processors - so you need to divide it by number of cores to get the normalized percentage.
Even after this, 'Live Metrics Stream' metric can be lower than AppServicePlan metric as the former only shows w3wp usage and the latter shows total machine cpu usage.
According to your description, I tried to run the load test against my Azure Web App. Here are the detailed metrics from Application Insights and App Service Plan, you could refer to it.
Application Insight > Metrics Explorer
Time range within an hour
PROCESS CPU: The percentage of elapsed time of all process threads used by the processor to execute the applications process.This metric is an average. Each point on the chart represents 1 minute of data.
App Service Plan > Monitoring
CPU percentage on the other hand is useful for apps hosted in basic, standard and premium plans since they can be scaled out and this metric is a good indication of the overall usage across all instances.
Note: Since the Live Metrics Stream provides you the metrics within the latest 60 seconds. Please try to compare the metrics from App Service Plan and Application Insights within the same Time range.
Per my understanding, the trend of metrics from Service Plan and Application Insights is approximately the same. For auto-scaling, I assumed that you'd better refer to the metrics from the App Service Plan level. Here is a screenshot about the history metrics when you adding the rule for auto-scaling, which matches the metrics from "App Service Plan > Monitoring" with the same time range.
Metrics when adding the scale rule:
App Service Plan > Monitoring

Resources