.NET Profilers are a developerâ€™s best friend when it comes to optimizing application performance. They are especially critical when doing low level CPU and memory optimizations. But did you know that there are three different types of profilers?
Traditional .NET profilers that track process memory usage, time spent per line of code and frequency of method calls.
Lightweight profilers or other tracing mechanisms that allow you to logically understand what your code is doing and understand performance at a high level.
Application performance management (APM) tools designed to monitor production servers.
All are very valuable but serve relatively different purposes and different types of performance profiling. Letâ€™s explore the different types.
1. Standard .NET Profilers
These tools include CLR profiler products like Visual Studioâ€™s .NET profiler, ANTS, dotTrace, SciTech and YourKit.
Most likely if you are using a profiler of some form, you are having a bad day. It usually means you are chasing some bad CPU or memory usage problems. Iâ€™ve had my fair share of multi-day marathon profiling sessions trying to find obscure memory leaks. These tools are a lifesaver when you need them, but they are very resource intensive and slow you down when using them.
I would venture to guess that the vast majority of developers have never or very rarely use these types of profilers. These simply arenâ€™t needed day to day for apps that a lot of developers create.
Traditional usage scenarios for a .NET profiler:
High memory usage: Profilers are extremely powerful when it comes to tracking down memory leaks and optimizing memory usage.
CPU usage is out of control: If your server CPU is extremely high and you have no idea why, a profiler may be your last resort to figure out why.
A standard .NET profiler works by using the .NET CLR profiling interface. This allows profiling the .NET MSIL bytecode at a low level to understand each operation your code performs. This enables them to show you the â€œhot pathâ€ within your code to see which methods are using the most CPU.
You can then typically drill down to even which line of code in your app is using the most CPU. This can be a huge lifesaver when you are having one of those bad days and need to urgently find the problem.
We proactively use the Visual Studio Profiler and ANTS to tune the performance of our Windows monitoring agent. Our goal is to add as little overhead as possible on the servers of our customers. We have also had to use them to chase down some weird memory leaks.
Lightweight profilers are more geared towards tracking the high level performance of your app. They help you understand total page load time, which database calls were executed, etc.
These tools are designed to help developers every single day. They are designed to not have a huge performance impact on your code so they can always be on.
There are three primary tools available to .NET developers that all work as ASP.NET Profilers. They are all very different in how they are implemented, how they work, and the types of information they can provide. Below is a real fast review and comparison.
Glimpse: Installed into your app and requires many config changes and nuget packages. Open source project now led by Microsoft. Glimpse does not use the .NET CLR profiler. Utilizes an extension and packages framework to add support for various app dependencies and technologies. Requires some code changes, for example, for tracking database queries you have to wrap your database connections in a special wrapper class. Only works with web apps.
MiniProfiler: Installed into your app as a lightweight tracing tool. It does not use the .NET CLR profiler. Database calls can be tracked by changing your code to wrap your SQL connections. You can also change your code to report additional steps within your code to include in the pseudo profile traces. Only works with web apps. Requires a lot of code changes.
Stackify Prefix: Installs on a developerâ€™s workstation outside of your app. Based on the .NET CLR profiler and uses the same technology that powers Stackifyâ€™s APM product for monitoring server apps. Requires no code or config changes to work! Automatically tracks the performance of 30+ common .NET frameworks and libraries. Can be used to view exceptions, logs, and much more. Can be extended to profile any method in your code. Also works with non web apps. This is our tool, so naturally we’re a little biased toward it.
These types of profilers are more designed around individual web requests or transaction tracing. This makes them very useful for tracking how long specific web requests take and why they are taking that long.
They can save a ton of time compared to writing a bunch of custom logging or debugging your code. They can put a lot of good information at your fingertips once they are setup. Every developer should have one of these tools in their toolbox.
Prefix is an amazing free tool. It is extremely easy to install and it just works with no headaches, code changes, or config changes. It is very lightweight and designed to be used every day. We have many users who leave it open on their second monitor all the time.
Sample screenshot of Prefix, Stackifyâ€™s free tool
3. Profiling Production .NET Applications (APM)
These tools include products like New Relic, AppDynamics, Stackify Retrace, Dynatrace, and others.
Normal profilers are designed as developer tools that are used on their workstations. The same sort of technology is used on servers but must be very lightweight so it doesnâ€™t slow down production applications. Stackifyâ€™s Retrace APM and Prefix use the same exact lightweight profiling technology for both.
The other key feature for profiling production apps is aggregating performance details across all transactions, app, and servers so you can easily understand application performance.
Reproducing application problems in QA or dev environments is usually a nightmare. One of the great things about APM products is they usually collect enough details to quickly identify and resolve most common application problems. Products like Stackify APM can show the exact database queries, logging, exceptions, web service calls and so much more to understand how to fix bugs or improve application performance.
The biggest problem with APM solutions is their pricing. They have traditionally been so expensive that only the largest enterprises could afford them. It doesnâ€™t make a lot of sense to spend $100 a month on a server at Azure or AWS and then spend another $150 a month for a product like New Relic. Monitoring tools shouldnâ€™t cost more than the servers!
Stackify Retrace is a very affordable APM solution that includes server monitoring, error tracking and log management for that price. However, the benefits of Retrace over New Relic go beyond pricing. Check out this quick comparison of features between the two.
Want even more power to write better code faster and catch any issues before they get to production?
Profilers are powerful tools for measuring and improving the performance of your apps in development and production both. I would highly recommend getting familiar with all three types of the .NET profilers mentioned in this article. They are tools that you should always have in your toolbox.
Digitalization is sweeping across many industries, creating a huge need for innovation. This innovation forces companies to be more agile and deliver faster. However, increasing the speed of your development team doesnâ€™t happen by magic. Itâ€™s a metric that isnâ€™t easy to change.
How can you adjust to this fast-paced digitalization? I want to introduce you to DevOps.
DevOps helps you deliver software in small chunks or features. The goal is to deliver new features quickly but in a stable way. In most cases, a DevOps team wants to release the product after each feature increment to the production or live environment.
Letâ€™s learn what DevOps is about, what tools it involves, and which benefits it can give you.
DevOps is a cultural shift because it tries to streamline both the operations and development teams. The idea is to share risks and responsibilities. Itâ€™s not about developing code and passing on the code to the operations team to be tested and deployed. With DevOps, both the development and operation team are responsible for testing the code and solving bugs as soon as possible.
DevOps tries to improve the efficiency of the whole development team by introducing short releases and streamlining both operations and development teams. Moreover, DevOps is all about introducing more automation tools for testing, building, and deploying software to the processes of the development team.
5 Reasons You Should Adopt DevOps
If you havenâ€™t made up your mind yet about switching to DevOps, take a look at the following reasons. You can also read about some of the DevOps success stories here.
1. Accelerating Innovation
The ability to move fast is of great importance for software companies and product companies. The success of a product is partially defined by its quality and ability to innovate more quickly than the competition.
To move more quickly than the competition, the DevOps approach helps to streamline the operations and development teams. DevOps can provide rapid feedback to your development team about a feature. This shorter feedback loop allows the team to move quickly and be more agile.
The largest benefit is the fact that your team will run the whole test suite every time it merges a new feature into the code. This process gives great feedback to the developers about the stability of the code after adding a new feature. DevOps allows your development team to find bugs early on in the software development cycle and allows team members to move much more quickly.
2. Merging Operations and Development Teams
You already know that DevOps culture is all about merging the operations and development teams. The DevOps culture tries to integrate both teams and have them share responsibilities, creating a more streamlined software development process.
3. Increasing Efficiency
DevOps introduces many automation tools for building software and executing various types of tests. This allows your team to produce software faster. Besides that, youâ€™ll receive quicker feedback, which will allow you to speed up the development process even more.
4. Reducing the Number of Bugs
DevOps lets you test code every time you add new functionality. By testing every small code increment, you can find bugs earlier in the software development life cycle. This allows your development team to resolve a bug almost instantly instead of patching it later on in the life cycle.
In short, DevOps supports a more agile approach toward software development. This agile approach can reduce the number of bugs and improve code quality.
5. Increasing Job Satisfaction
DevOps is all about sharing risks and creating a productive work environment. Also, it embraces riskier moves that help spark innovation.
In addition, DevOps reduces bureaucratic obstacles that can slow the team down. Itâ€™s all about creating one shared, efficient workspace.
Challenges to DevOps
Many teams wonder how they can start implementing a DevOps culture. Letâ€™s discuss some of the challenges your team may face during the transition.
Moving From Manual to Automated Testing
The first challenge is related to transitioning from a manual testing approach toward automated testing. Getting your testing environment right takes time. Moreover, your organization might want to hire some extra resources who are experts in setting up an automated environment.
Moving From Big to Small Releases
You might test and deploy your product every three months. In contrast, DevOps encourages you to develop a release plan that embraces small functionality releases.
However, itâ€™s not easy to split up your release plan into smaller chunks of functionality that you can release every two weeks.
To make this change, developers need to embrace testing as part of their coding routine. Every small release needs to be tested first before it can go to the production environment.
Changes often lead to resistance. This rule also applies to merging your operations and development teams. Youâ€™ll have to work on streamlining processes and communication to successfully merge both teams. This means that your teams will have to learn and adopt new processes. For example, the development team needs to provide one developer who can assist the operations team with defining test cases for testing a new piece of functionality.
No DevOps Vision or Strategy
Itâ€™s hard to fully embrace the DevOps culture. Youâ€™ll need a clear vision and strategy. Often, youâ€™ll want to develop a release plan that facilitates a DevOps vision by making the plan more agile, but youâ€™ll also think about how different bits of code can influence one another or slow down development. If you can think with a DevOps mindset, youâ€™ll gain much more efficiency.
In this last section, letâ€™s look at some tools that people often use when implementing a DevOps culture.
The first tool is Chef, which is an open source systems management and cloud infrastructure automation platform. Chef can manage virtual machines, containers, and servers. Chef uses so-called recipes and cookbooks that abstract complex configuration. To give an example, the keyword directory followed by a path creates a new directory for this path. Itâ€™s a simple approach to creating automated flows.
Retrace is a tool from the Stackify team. The tool helps development teams monitor their applications, gain insights and metrics, and aggregate logs for later use. It also offers error tracking and code profiling to identify performance problems.
Jenkins may be the most popular open source, continuous integration tool developed in Java. It allows developers to get fast feedback about their code changes. It can isolate new code changes in a large code base, so you can test code much faster. Itâ€™s one of the most important tools for the DevOps team to get insights into the quality of an application.
Kubernetes is one of the most commonly used tools for managing containers. Hereâ€™s a snippet from the Kubernetes documentation: â€œKubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. It has a large, rapidly growing ecosystem.â€ Google maintains the tool and began open sourcing Kubernetes in 2014.
DevOps culture is gaining in popularity because of its efficiency. When you decide to align your operations and development teams, I recommend changing gradually. It requires time to streamline both teams and set up the automated development flow. Next up, read about key metrics for your DevOps implementation.
Want to learn more about the difference between a traditional software development cycle and DevOps? Check out this article by Sunil Karke.