How to fine tune an asp.net application and find bottlenecks - c#

How can I test performance of an asp.net mvc application and understand where exactly the bottlenecks are? I see some tools from redgate but to get the package is about $700. Are there any cheaper alternatives that may work? Or simple ways to really fine tune the application to maximize performance in a less expensive manner?
Thanks.

Sure. There is one stackoverflow created called MiniProfiler.
http://code.google.com/p/mvc-mini-profiler/
http://www.hanselman.com/blog/NuGetPackageOfTheWeek9ASPNETMiniProfilerFromStackExchangeRocksYourWorld.aspx

If you're using VS 2010 Ultimate you have access to some decent performance testing tools that are included. Many time bottlenecks only show themselves when the application is under load. The tools in VS let you correlate the load test with performance counters on the server hosting the app. This in combination with the MiniProfiler tool mentioned in another answer would be a good combo for finding bottlenecks.
http://msdn.microsoft.com/en-us/library/dd293540.aspx

Related

Continuous Integration for stack with Visual C++ and C#

Please recommend a good continuous integration that would build and integrate with the .net stack and the visual c++ as well.
Some recommendations I have got are
Jenkins
CruiseControl
Teamcity
Because of the polyglot nature of the project, which continuous integration solution would you recommend?
I have used all three over several years. Some of the answers below state that most of the work will be producing your own build scripts. This has been true in my experience as well. We use a combination of MSBuild and Powershell scripts for our build process, which can be run under just about any CI tool, so picking one comes down to what you're looking for in terms of customization, integration with other systems, performance, and ease of use.
Short answer:
I recommend Jenkins. So far it seems to be the best combination of the above qualities. It has a ton of plugins, some localization and is actively developed by the OSS community.
Long answer:
I started with Cruise Control .Net. It was easily configurable with a text file and I found it highly reliable. However, we moved away from it because Thoughtworks was moving toward a paid product (Cruise, now Go) and future development was in question. A new team has since forked the project but there is little word about future development since.
We moved to TeamCity, which is free and has a great ajax-y UI. It is easy to setup and get going and has a lot of features for distributed builds. We quit using TeamCity for several reasons. The server does a ton of stuff and it was a bit overkill for our basic needs. Even so, it was not very customizable (see Time Zones and notification contents) and we often found the administration UI confusing. That was all still okay, but we also had steadily worsening performance problems. We started with a standard HSSQLDB out-of-the-box, moved our installation to SQL server when we started experiencing degraded performance, then had to quit using the server at all as performance continued to degrade over time. I'm not sure what the culprit was but I couldn't find any cleanup to do that would explain the constantly worsening performance as the Tomcat web server fought with SQL Server for resources, even when there were no active builds running. I am sure it's my fault and I was missing some crucial setting or needed to feed the server more memory, but this is a shared utility box, we did not have these issues with CC.Net, and most of all, I am not a Java/Tomcat guy and don't have a lot of extra time to keep fighting with these issues.
We've moved to Jenkins now. It seems to be working fine so far but we've only been with it a short while. It was easy to set up, does not seem to be taking nearly as many resources as TeamCity and has a ridiculous number of plugins. The only downside so far is like many OSS products, it does not seem to have the best documentation and it does so much that I may be tweaking knobs for a while to get it set up the way we want.
Between CruiseControl and TeamCity, TeamCity is faster and easier to set up, but you may need to check on licensing for it. I can't speak to Jenkins, never having used it.
Jenkins has the big advantage of being very extensible (currently over 400 plugins), which allows you to combine it with a huge number of other tools. So it gives you complete freedom in your other tool choices. I recently read that this is one problem of TeamCity, that you get locked in using the whole stack of tools (e.g. using SVN or Git as version control system will not be possible).
I am using Jenkins myself for our projects which has both Java and C++ code, and I am very happy with the tool. We had CruiseControl before, and have not once regretted the switch.
I have tried both Cruise Control and Jenkins, and Jenkins impressed me with very fast and user-friendly set up.
The three you list are all sensible choices, and the main problem will be producing the build script(s) needed to do produce the build artifact(s). If you manage to make them do everything needed, changing CI system shouldn't be a big issue.
After implementing all three in different shops, I'd chose all of the above. Pick one.

Windows Service and Performance Info using C#

We have hundreds of database and application servers in our datacenter and we are currently using various third party tools to monitor. All appear to have their stengths and weaknesses.
I would like to create a simple Windows Service using C# that can check the most common performance counters on a Windows system every 5 mins or so and upload the results to a WCF service.
My questions are:
1) Having never worked with Performance Counters in .NET, is this something that is fairly simple to do?
2) Are there any permission issues I need to concern myself with? The service will likely be running under "localsystem" or a domain user account.
3) What are the common performance counters I should be looking for... Memory, CPU, Disk?
4) Has anyone else written code similar to this and do they have any examples to get me started?
Any help would be appreciated.
Monitoring performance counters isn't hard using .NET however I recommend using existing tools (such as SCOM) that will do exactly this for you.
In case others may find this useful (or myself in the future) ;)
Yes - Performance Counters
Unfortunately I don't know the answer to this one, but I'll update if I learn it. :D
This will depend on the context. You will likely want to monitor slightly different counters for Database servers vs Application servers. There are many excellent resources on this.
Here are a couple key files I found on various projects on Github. They may not be ideal, or reflect the above articles, but they give an idea on the structure. You can also refer to the examples in the official documentation on the PerformanceCounter Class.
TelemetryInstrumentService.cs by Scott DeHaan
CounterWatcher.cs by CryptonZylog

Lightweight profiling for Silverlight?

I would like to profile certain actions in my application in a production environment.
I have previously used Stopwatch in .NET
It does not seem to exist in Silverlight (despite being in the documentation).
Can anyone suggest some alternatives? Is there anything better than DateTime.UtcNow?
I have used Yourkit and use ANTs in development, but I would like to gather information about performance of deployed software. I do not have access to the kind of data the users have, but can gather some logging.
Is this post any use at all?
It sounds like you want to deploy profiling IN your application so you can see how it performs on the user's PC?
Firstly you could have a look at this answer. Standard timers (eg looking at the value of DateTime.Now) are only going to give you rough resolution, which seems to be around 16ms at best.
Otherwise you can grab a performance profiling tool, there are several now which work out of the box with Silverlight, are easy enough to use and don't really take that long to get started with, with free evaluations. Two such tools JetBrains dotTrace and RedGate ANTS
Have you looked at this question: How to profile a silverlight application?
Are you looking for something other than this?
Telerik also has a pretty fantastic product for profiling named : JustTrace
JustTrace enables the profiling of local applications, running applications, Silverlight applications and local ASP .NET web site.

Code Profiling ASP.NET MVC2 applications

The thread here seems close:
Profiling ASP.NET websites with EQATEC Profiler
However, in the free version of Equatec I downloaded today there is no checkboxes for ASP.NET, and ordinary web. I have pointed the App path to my bin directory in my project folder as well as started up the localhost hosting for my application via Visual Studio.
I am open to other free tools as well. I am just looking for someway to profile the code as to optimize some reflection we are using.
I am using the professional edition so unfortunantly do not have access to MS Code Profiling.
I am looking to do performance profiling at this point.
Is the free version of Equatec capable of doing ASP.NET applications?
Is there a free profiler (I realize this has been asked before, and little seems to have surfaced but paid apps, but might as well ask)?
Is MVC a special thing to look for in a profiler?
Comprehensive profiling tools still seem to be quite expensive. I like the dotTrace family, but they're not free.
You haven't specified what kind of profiling you want to do. Are you trying to understand more about the memory usage of your application, or CPU usage?
There is nothing special about MVC applications when it comes to profiling. You will need a profiler that's capable of launching ASP.NET. Beyond that, MVC is just a regular bunch of class libraries.
Have you tried the free CLR Profiler? It handles ASP.NET and will show both memory and some method call activity. It's not as comprehensive as say dotTrace, but it is a great free alternative if you're starting out.
The guide is actually not out of date: the few steps described in the stackoverflow duplicate question (last edited April 8th) still describes best how you should profile ASP.NET apps. Note that you should look at the accepted answer, the one with currently 16 upvotes.
After you've build the instrumented app the important thing to note in the stackoverflow-answer above is step 3: "load your app". It means that you should cause your app to be loaded and is the only step the profiler can't do automatically for ASP.NET apps.
You typically load the app simply by navigating to it in a browser so you simply need to do that after the build-step. When your (instrumented) code is activated the profiling part of it will spring into life and connect to the profiler and then you can take snapshots.
Note that ASP.NET doesn't need a main entry point. That's just an added convenience for automatically taking snapshots for real executables that has a Main method.
You just need a .NET profiler.
Profiling WebForms, MVC, SharePoint, Sitecore, Ektron, Sitefinity, or any other product that runs on .NET doesn't change that.

Is there any way to profile performance of a WCF Application?

We're trying to measure performance of our system, which is a .NET 3.5 application that uses WCF calls.
Problem is until now, we weren't able to profile the methods inside these calls. A winforms client application was coded to test our system. We tried using ANTS 4 Profiler and VS2008 built-in Performance Analyzer, but we only got the total time of the WCF call. We would like to be able to measure all the calls that are being made inside of the WCF call.
Does anybody know if that's possible?
Thanks in advance.
There is quite a bit of performance testing functionality built into Visual Studio Team System Test Edition.
Take a look on this page and scroll down to the section Introduction to Load Tests.
Also this WCF Load Test application on codeplex might be helpful
So your application can run under VS, but WCF calls off to an environment where you cannot get profiling visibility, but you want to know what goes on in there?
Even if you find out how WCF uses time inside itself, any changes you make will have to be in your code. If you want to find out where in your code you can do something about performance, you can use the VS profiler. Personally, I just use stackshots, which are very effective at finding out what code to optimize under any environment, including C#.

Categories

Resources