One of the best things about being a .NET developer is all the amazing ASP.NET performance tools that can make your life easier. This blog post is a list of the various types of ASP.NET performance tools at your disposal for finding and optimizing ASP.NET performance problems. Depending on the task, some of these tools will be much better than the others.
If you are trying to tweak the performance of your code line by line, a good code profiler is your friend. They work great for those times when you have a console app and want to run a certain method 1,000 times to tweak CPU and memory usage. They also work great attached to existing Windows Services or ASP.NET apps to find the hot paths in your code.
I’m not sure how to categorize these, but there are a couple of great options for analyzing the performance of your ASP.NET apps without doing full code profiling. These solutions all capture detailed transaction traces about each ASP.NET web request.
Glimpse and the Miniprofiler work differently than each other but both basically allow you to understand some details about the performance of your app while in development or production. But only for the performance of the current request you are executing, a la, ASP.NET profiling.
Review of Prefix: A lightweight ASP.NET profiler helping you write better software
Tools like Prefix can provide very detailed traces of what your code is doing:
Application performance management tools offer the best of both of the previous two categories. They are designed to do lightweight code profiling on every single web request that won’t impact the performance of your applications. They can collect the high-level details you need to identify common performance problems and monitor your production apps nonstop to ensure they are always working properly.
Note: Some providers, including Stackify, provide free trials that can be used to help identify immediate problems.
Compare: Stackify Retrace vs New Relic, Stackify Retrace vs App Insights
Read More: Azure Service Profiler review – How does it fit in your toolbox?
How to Monitor IIS Performance
Most applications these days use a lot of JavaScript. To track the performance of how long it takes your users to download all of the JavaScript, CSS, and images for your site and render them, you will use a real user monitoring (RUM) solution.
Most APM providers also provide real user monitoring. There are also numerous providers of only real user monitoring, including load balancer providers.
Stackify Retrace provides real user monitoring as part of its performance management solutions. With Retrace’s RUM, you will be alerted when your customers are having poor experiences. Then, it automatically points your UI engineers to how and where it can be fixed.
Read More: Stackify Retrace Real User Monitoring Getting Started
Microsoft provides a lot of built-in metrics related to the CLR, ASP.NET, IIS app pools, and much more. Some of the most important ones when it comes to tracking performance are related to garbage collection, request queuing, memory usage, CPU usage, HTTP error rates, and many more.
Read more: Performance Counters for ASP.NET on MSDN
One of the best ways to track the performance of your app is by creating your own custom application metrics and tracking them. If you want to track your own custom metrics, you can make your own Windows performance counters, use statsd, or numerous 3rd party services.
As an example of how you can use custom metrics, at Stackify we use a lot of them to track things like how many metrics or log messages we have coming inbound per minute. We also track how long it takes to process them at every step in the pipeline. These kinds of metrics are very valuable for application monitoring and troubleshooting purposes.
How to: Create Custom Performance Counters with C#
Note: Many application monitoring type products may have libraries or an API available for supporting custom metrics as part of a larger monitoring product. Check if your current tools support it.
If you want to track how long it takes a particular request to load, you can quickly open or tail your IIS log files. You could even aggregate all of them, parse, and query them to identify your top used requests, slowest requests, etc. Doing this on your own can be complex if you are trying to monitor them ongoing. You can also ship all of your logs to a 3rd party log management tool that is designed to help you search and visualize all of your logs.
If you don’t have an APM solution, parsing your IIS logs is one way to do basic ASP.NET performance monitoring.
Read more: 13 Ways to Tail a Log File on Windows & Linux
One of the lesser-known and used features of IIS is failed request tracing. It can be used to trace lots of details about IIS requests that meet certain rules that you can configure. You can set them up for certain HTTP status codes, time taken, or event severity level.
One of the biggest causes of performance problems can be application exceptions. When an exception is thrown it causes the thread to pause while the stack trace is collected. Even handled exceptions that seem innocent can cause huge performance bottlenecks under heavy server load. It is important to aggregate and monitor all of your exceptions to find critical problems, new errors, and monitor error rates over time. Error or bug tracking tools are essential for any development team.
Read more: How GWB Found Hidden Exceptions and Application Performance Problems
Learn More: Advanced Error Monitoring, Tracking & Reporting with Retrace
Note: Manually catching and reporting errors in your code to a logging framework is a great way to collect errors. But you will likely never cover every single possible way an error could occur by doing so. Many APM providers can also collect errors via the .NET CLR Profiling APIs and that gives them visibility to every single error ever thrown. This method can collect a lot of noisy errors, but this can be really valuable for finding and eliminating unnecessary exceptions you may not otherwise know exist.
Some other options that can be helpful in certain situations are ETW, WMI, WinDbg or even the CLR Profiler API itself. Although these are all very low level and require some experience to know what to do with.
WinDbg is a really powerful tool for analyzing weird ASP.NET problems. Check out this blog post where we discuss using WinDbg to solve a problem caused by an async thread throwing an exception.
Depending on what you are trying to accomplish, there are a lot of ASP.NET performance tools available to you. Every application problem is different. Over time you will probably use all of the different types of tools listed here. It is really good to at least know what options are available to you and we hope you found this list helpful. Have other ideas that should be on our list? Let us by commenting our pinging us on Twitter @Stackify.
Learn how to put these tools to work: How to Troubleshoot IIS Worker Process (w3wp) High CPU Usage
Need help identifying and monitoring ASP.NET performance problems? Try a free trial of Stackify Retrace or learn more.
If you would like to be a guest contributor to the Stackify blog please reach out to [email protected]