简体   繁体   English

ASP.Net性能

[英]ASP.Net Performance

I am configuring an ASP.Net (VB.Net) application on my system. 我正在系统上配置ASP.Net(VB.Net)应用程序。 I have Visual Studio 2010 and also have compiled the code and deployed the compiled version on a server. 我安装了Visual Studio 2010,还编译了代码并将编译后的版本部署在服务器上。 On both places I get the response of the pages after so long (as long as more than a minute). 在很长一段时间(长达一分钟以上)之后,我在两个地方都得到了页面的响应。

Strange thing: 奇怪的事情:

I have put code to calculate the time it takes from entry to Page load handler to exit from Page close handler which is normal (less than a second). 我已经放入代码来计算从进入页面加载处理程序到从页面关闭处理程序退出所花费的时间,这是正常的(不到一秒钟)。 The application does not have any http modules, neither it has Global.asax nor the page has other overriden handlers. 该应用程序没有任何http模块,也没有Global.asax,页面也没有其他重写处理程序。

Question1: If the time between page load and page close is so small why is it taking too long to respond? Question1:如果页面加载到页面关闭之间的时间太短,为什么响应时间太长? Question2: What techniques I can use to actually debug what is happening when it is awaited response? 问题2:在等待响应时,我可以使用哪些技术来实际调试正在发生的情况?

Thanks in advance. 提前致谢。

-----update--------- in response to krshekhar's question below I'm attaching screenshot of the page response I got from HttpWatch ----- update ---------为了回应下面的krshekhar问题,我附上了从HttpWatch获得的页面响应的屏幕截图

在此处输入图片说明

What is the size of the page? 页面的大小是多少?
Use Mozilla Firefox. 使用Mozilla Firefox。
Download firebug 下载萤火虫
Install add on why-slow yahoo add on. 在add -why-slow yahoo上安装add。
And see the option available in the report. 并查看报告中可用的选项。

You mention the "page close" handler - what is this? 您提到了“页面关闭”处理程序-这是什么? The page close event is a browser event, rather than a server one, so I am unclear as to how this is being fired. 页面关闭事件是浏览器事件,而不是服务器事件,因此我不清楚如何触发该事件。

From your trace, I am assuming that master.aspx is taking 270 seconds from client request being sent to render being completed for only 31000 bytes of information. 根据您的跟踪,我假设master.aspx从发送客户端请求到渲染仅花费31000字节信息就花费了270秒。 Given that this is happening locally as well as when deployed to the server, this makes it likely that there is at least one section of code that is taking a significant amount of time to execute. 鉴于这是在本地以及在部署到服务器时发生的,这使得至少有一部分代码可能要花费大量时间才能执行。

What I would recommend to start with is to add debug to your page load event to see how long this is taking to run. 我建议首先将debug添加到页面加载事件中,以查看运行该过程需要多长时间。 I'd simply do this with Debug.WriteLine("Point x reached at " & Now.ToString("yyyy-MM-dd hh:mm:ss.nnn) to start with to give you an idea at what time you are hitting each piece of code. From there you may see an obvious area that is taking a long time. 我只需要使用Debug.WriteLine(“点x到达&&Now.ToString(” yyyy-MM-dd hh:mm:ss.nnn)来完成此操作,就可以知道何时打每段代码。从那里您可能会看到一个很长的区域。

I wouldn't be at all surprised if you find that your data fetches are taking longer than expected - are you using multi-threaded data loading at all? 如果您发现数据获取花费的时间比预期的长,我不会感到惊讶-您是否正在使用多线程数据加载?

Try timing from the Page_PreInit event until the Page_Unload event. 尝试从Page_PreInit事件直到Page_Unload事件计时。 That should give you a more decent view. 那应该给你一个更体面的看法。 Also is the timing you posted for a normal LOAD, or a SUBMIT (or postback) event? 您发布常规LOAD或SUBMIT(或回发)事件的时间也是吗?

Plus, is your database connection being handled INSIDE your codes or outside (ie, would the timing be able to catch the time it takes to make the necessary network connection)? 另外,您的数据库连接是在代码内部还是外部处理的(即,时间是否能够赶上进行必要的网络连接所花费的时间)?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM