Hello Everyone, My name is Puneet Gupta and I work as a Senior Software
Engineer in the Azure App Services Diagnostics team.
Our team enables customers to self diagnose their apps hosted on Azure App
service. In this video, we will learn about effectively measuring CPU consumption for apps
hosted in Azure App Service and see how we can accurately identify apps
that are consuming most of the CPU resources. In future videos,
we will dig deeper into troubleshooting tools that allow you to debug a specific
app but the first step is identifying which app is consuming the maximum CPU.
resources. App Services provides Linux and docker hosting
scenarios as well but we will be covering App Services hosted on
the Windows stack. Also, we will be focusing on Apps which are running in a
Dedicated SKU. Thirdly, the approach shown in this video can be applied to
apps built using any framework or technology be it ASP.NET,
ASP.NET CORE, Node, PHP, Java, Python etc.
So, we start by going to Diagnose and Solve problems blade for my app. Here,
you can see different categories and checks that you can run to ensure your
app runs healthy and is following best practices and recommendations.
As we are interested in identifying CPU consumption, lets go to the Availability
and Performance section. Under this section,
we run a quick health check on your app and we highlight key aspects of the
app that you should care about. The time duration defaults to last 24 hours
but you can modify it if needed. We can see the
apps failed request rate, app performance shown as 90th Percentile of
request execution time, maximum CPU percentage,
across all instances and the maximum Private bytes of memory
consumption by the app. We can clearly see in this case that the CPU
usage is high. This number indicates the maximum CPU usage
of the App Service Plan hosting your app. An App Service Plan may have
multiple apps so lets try to identify why the CPU usage is 100%
We can do this by clicking the High CPU analysis
on the left or by clicking the CPU usage tile on the health check page
High CPU analysis helps in troubleshooting
issues related to CPU. The very first thing it checks
is the App Service Plan density. This check ensures that you have not
over-stuffed the App Service Plan by putting too many sites on it and it calls
out if you are within the safe limits or not. In this case we are
fine as we are only running 3 active apps in the app service plan which is
within the safe limits for this SKU. Next, it identifies
the app which is consuming maximum CPU resources on the app service plan.
In this case, it has identified that there is only one app
which is consming most of the resources. Notice,
that the app that is consuming the highest CPU is different from
the app which we are currently looking at. The tool also
suggests the next steps to further debug the app.
Going down further, we see overall CPU usage for all
instances associated with the app service plan. In this
case, we can see that the app is running on 2 instances and both are
consuming high CPU. We can choose a point on the graph to see CPU usage
for each instance at a given point in time. We also have
a drilldown view that shows you App Level CPU consumption for apps running
on the same app service plan. By default, the instance
with the maximum CPU usage is selected and the graph shows individual CPU
consumption of each app running on the instance.
The CPU usage shown here is the CPU usage of the process
belonging to the app and the all the child processes spun up
to serve the app. We can see from the graph, CPU usage of each
app at a given point in time. Next we see a process level
breakdown of each app. The app that is consuming the maximum CPU
is preselected and you can see the process name and process Id
for all the processes that belong to this app.
You can switch the dropdown view to see the process level breakdown of
other apps running in the same app service plan. In this manner,
we can determine the app or apps that are spiking the maximum CPU
on every instance.
This is the simple workflow to be followed based on what is identified
by running the High CPU analysis tool. If a single app is
consuming most of the CPU, then we should be debugging the
app to identify why the CPU is high. You can
temporarily mitigate the issue by restarting the app as well
because that might recover the high CPU situation for some time. If you
are on a lower tier like B1 or S1, you can upgrade the tier
to the next tier, so that you are instance gets more compute resources.
If multiple apps are consuming high CPU,
then its better to scale up the app service plan to the next tier, so that
apps get more compute resources. It might be related to the
load of requests you are getting. You can also move some apps to a dedicated
app service plan to ensure that they don't end up impacting other important
apps. So in our example we saw that
"demohighcpu" is consuming maximum CPU.
Hence, it makes sense for us to debug this app further
to identify why it is causing high CPU. This is something that we will
cover in the next video. With that, we have to an end. Do let
us know if you find this helping and if you have any feedback or suggestions
and stay tuned for any upcoming videos on this topic. Thank you for watching!