Possible Handle Leak on Azure App Service App

Krishnadas K P_FT 5 Reputation points
2023-01-23T04:59:13.44+00:00

We have an ASP.NET 4.8 application hosted in Azure App Service. At times we see a spike in latency in usually a single instance which also shows spikes in CPU time, TCP connections, Thread Count and Handle count. The average thread count and and average handle count spikes from about 100 to 450 and 4000 to 8000+ respectively. We did an investigation by analysing memory dumps through windbg and could see the number of Event and Thread handles were unusually high at this time. The thread and handle count does not come down for quite a few time, but the latency is only felt right at the beginning of this spike. So we believe the CPU time and latency spikes are due to the cost of thread and handle spawning.

How can we further debug the potential handle or thread leak issue ? I am not able to find out what requests are causing the spikes in thread and handle from windbg. I read some docs but still not getting clarity on what is thread and event handles.

ASP.NET
ASP.NET
A set of technologies in the .NET Framework for building web applications and XML web services.
3,394 questions
Azure ISV (Independent Software Vendors) and Startups
Azure ISV (Independent Software Vendors) and Startups
Azure: A cloud computing platform and infrastructure for building, deploying and managing applications and services through a worldwide network of Microsoft-managed datacenters.ISV (Independent Software Vendors) and Startups: A Microsoft program that helps customers adopt Microsoft Cloud solutions and drive user adoption.
91 questions
Azure App Service
Azure App Service
Azure App Service is a service used to create and deploy scalable, mission-critical web apps.
7,259 questions
{count} vote

1 answer

Sort by: Most helpful
  1. Ryan Hill 26,866 Reputation points Microsoft Employee
    2023-01-26T05:06:04.6366667+00:00

    @Krishnadas K P_FT I'm assuming you're already familiar with the DaaS options in the Diagnose and solve problems blade. In addition to what was mentioned above, I would suggest collecting a .NET Profiler trace.

    User's image

    If needed, you can extend the profiling timeout, which defaults to 60 seconds, by setting APPSETTING_IIS_PROFILING_TIMEOUT_IN_SECONDS application setting. The .diagsession file the profiler returns you can actually examine inside Perfview. I would also advise reviewing this app service blog post for more information regarding profiling your ASP.NET application.