ASP.NET启动性能分析网站 [英] ASP.NET startup Performance profiling web

查看:87
本文介绍了ASP.NET启动性能分析网站的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试确定ASP.NET应用程序启动时间过长(恕我直言)的原因.

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

该应用程序使用各种第三方库,并且我敢肯定可以合并很多引用,但是,我试图识别(并归咎于dll)dll及其对扩展启动过程的贡献.

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.

到目前为止,启动时间从2到5分钟不等,具体取决于包装盒上其他物品的使用情况.基于网站的复杂性,我认为这是不可接受的,我需要将其减少到最多30秒左右.

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.

要明确我要寻找的性能范围,这是从第一个请求到最初的Application_Start方法被命中的时间.

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.

所以我将从哪里开始获取有关哪些DLL的加载以及加载所需时间的信息,因此我可以尝试将需要解决/合并的成本/收益加在一起.

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.

从能力的角度来看,我已经使用JetBrains dotTrace已有一段时间了,而且一旦进入应用程序后,我就清楚如何对应用程序进行基准测试,但这似乎超出了应用程序代码的范围,因此在我目前所不知道的范围之外.

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.

注意:我知道我可以在回收/升级上调用默认页面来进行初始加载,但是我宁愿解决实际问题,也不必在上面写下文件.

注2:硬件在功能上已足够扩展和分离,因此我很确定这不是问题.

推荐答案

分析/调试启动代码的单独答案:

Separate answer on profiling/debugging start up code:

w3wp只是一个运行.Net代码的进程.因此,您可以使用所有用于普通.Net应用程序的性能分析和调试工具.

w3wp is just a process that runs .Net code. So you can use all profiling and debugging tools you would use for normal .Net application.

棘手的一点是,w3wp进程会在对应用程序的首次请求时自动启动,并且如果您的工具不支持在每次启动时附加到进程,则调查应用程序的启动代码会很麻烦.

One tricky point is that w3wp process starts automatically on first request to an application and if your tools do not support attaching to process whenever it start it makes problematic to investigate startup code of your application.

解决问题的技巧是将另一个应用程序添加到同一应用程序池中.这样,您可以通过导航到另一个应用程序来触发w3wp的创建,而不是针对已经运行的进程附加/配置工具.当您最终触发原始应用程序工具时,将看到在现有的w3wp进程中正在进行加载.

Trick to solve it is to add another application to the same Application Pool. This way you can trigger w3wp creation by navigating to another application, than attach/configure your tools against already running process. When you finally trigger your original application tools will see loading happening in existing w3wp process.

有2-5分钟的延迟,您甚至可能不需要探查器-只需按照上面建议的方式连接Visual Studio调试器,并在加载网站时随机触发几次全部中断".很有可能代码的最慢部分将位于许多线程之一的堆栈中.还要提防调试输出-可能会为您提供一些线索.

With 2-5 minutes delay you may not even need profiler - simply attach Visual Studio debugger the way suggested above and randomly trigger "break all" several times during load of your site. There is a good chance that slowest portion of the code will be on the stack of one of many threads. Also watch out for debug output - may give you some clues what is going on.

您还可以使用WinDbg以类似的方式捕获所有线程的堆栈(可能比VS更轻便).

You may also use WinDbg to capture stacks of all threads in similar way (could be more light way than VS).

这篇关于ASP.NET启动性能分析网站的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆