Profiling and output caching in ASP.NET MVC
So I was recently hired by a big department of a Fortune 50 company, straight out of college. I’ll be supporting a brand new ASP.NET MVC app – over a million lines of code written by contractors over 4 years. The system works great with up to 3 or 4 simultaneous requests, but becomes very slow with more. It’s supposed to go live in 2 weeks … I’m looking for practical advice on how to drastically improve the scalability.
The advice I was given in Uni is to always run a profiler first. I’ve already secured a sizeable tools budget with my manager, so price wouldn’t be a problem. What is a good or even the best profiler for ASP.NET MVC?
I’m also looking at adding caching. There is currently no second level and query cache configured for nHibernate. My current thinking is to use Redis for that purpose. Also looking at output caching, but unfortunately the majority of the users will login to the site. Is there a way to still cache parts of the pages served by MVC?
2 Solutions collect form web for “Profiling and output caching in ASP.NET MVC”
Do you have any monitoring or instrumentation setup for the application? If not, I would highly recommend starting there. I’ve been using New Relic for a few years with ASP.NET apps and been very happy with it.
Right off the bat you get a nice graph of request response times broken down into 3 kind of tasks that contribute to the response time
- .NET CLR – Time spent running .NET code
- Database – Time spent waiting on SQL requests
- Request Queue – Time spent waiting for application workers to become available
It also breaks down performance by MVC action so you can see which ones are the slowest. You also get a breakdown of performance per database query. I’ve used this many times to detect procedures that were way too slow for heavy production loads.
I would highly recommend you use some instrumentation software like this. It will definitely get you pointed in the right direction and help you keep your app available and healthy.
Profiler is a handy tool to watch how apps communicate with your database and debug odd behaviour. It’s not a long-term solution for performance instrumentation given that it puts a load on your server and the results require quite a bit of laborious processing and digestion to paint a clear picture for you.
Random thought: check out your application pool configuration and keep and eye out in the event log for too many recycling events. When an application pool recycles, it takes a long time to become responsive again. It’s just one of those things can kill performance and you can rip your hair out trying to track it down. Improper recycling settings bit me recently so that’s why I mention it.
For nHibernate analysis (session queries, caching, execution time) you could use HibernatingRhinos Profiler. It’s developed by the guys that developed nhibernate, so you know it will work really good with it.
Here is the URL for it:
You could give it a try and decide if it helps you or not.