Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET startup Performance profiling web

I'm trying to determine the cause of a very long (imho) initial start up of an ASP.NET application.

The application uses various third party libraries, and lots of references that I'm sure could be consolidated, however, I'm trying to identify (and apportion blame) the dlls and how much they contribute to the extended startup process.

So far, the start up times vary from 2-5 minutes depending on usage of other things on the box. This is unacceptable in my opinion based on the complexity of the site, and I need to reduce this to something in the region of 30 seconds maximum.

To be clear on the scope of the performance I'm looking for, it's the time from first request to the initial Application_Start method being hit.

So where would I start with getting information on which DLL's are loaded, and how long they take to load so I can try to put a cost/benefit together on which we need to tackle/consolidate.

From an ability perspective, I've been using JetBrains dotTrace for a while, and I'm clear on how benchmark the application once we're in the application, but it appears this is outside of the application code, and therefore outside of what I currently know.

What I'm looking for is methodologies on how to get visibility of what is happening before the first entry point into my code.

Note: I know that I can call the default page on recycle/upgrade to do an initial load, but I'd rather solve the actual problem rather than papering over it.

Note2: the hardware is more than sufficiently scaled and separated in terms of functionality, therefore I'm fairly sure that this isn't the issue.

like image 273
Martin Avatar asked Jun 06 '12 16:06

Martin


2 Answers

Entertainment options check along with profiling:

  • profile everything, add time tracing to everything and log the information
  • if you have many ASPX views that need to be compiled on startup (I think it is default for release configuration) than it will take some time
  • references to Web services or other XML serialization related code will need to compile serialization assemblies if none are present yet
  • access to remote services (including local SQL) may require the services start up too
  • aggressive caching in application/remote services may require per-population of caches

Production:

  • What is the goal for start up time? Figure out it first, otherwise you will not be able to reach it.
  • What is price you are willing to pay to decrease start up time. Adding 1-10 more servers may be cheaper than spending months of development/test time and delaying the product.
  • Consider multiple servers, rolling restarts with warm up calls, web gardens
  • If caching of DB objects or in general is an issue consider existing distributed in-memory caches...
like image 191
Alexei Levenkov Avatar answered Oct 22 '22 00:10

Alexei Levenkov


Your DLL references are loaded as needed, not all at once.

Do external references slow down my ASP.NET application? (VS: Add Reference dialog)

If startup is taking 2-5 minutes, I would look at what happens in Application_Start, and at what the DLLs do once loaded. Are they trying to connect to a remote service that is very slow? Is the machine far too small for what it's doing (e.g. running a DB with large amounts of data plus the web server on an AWS micro instance or similar)?

Since the load time is probably not the IIS worker process resolving references, I would turn to traditional application profilers (e.g. Jetbrains, Antz, dotTrace) to see where the time is being spent as the DLLs initialize, and in your Application_Start method.

like image 37
Eric J. Avatar answered Oct 22 '22 01:10

Eric J.