随机慢网页加载加载、网页

2023-09-06 16:40:41 作者:lovely day(美好的一天)

这是不容易解释什么是真正的问题,但我尽量; - 。)

It's not easy to explain what the problem really is, but I try to ;-).

下面是一些数据:

在用IIS7(不RC2)的Microsoft服务器 3GB内存 只有这个应用程序是此服务器上 在SQL Server 2008前preSS Repository模式 SimpleInjector MVCSitemapProvider

好了,现在的问题。这不是启动,因为该网站在2秒加载。之后,应用程序池回收。页被在200毫秒或更小(或更大)加载,但有时在启动后(我不能时,因为它是随机说,其回收后不)他们需要长达2分钟或更长时间。

Ok now to the problem. It's not the startup because the site is loaded in 2sec. after app pool recycling. After the startup the pages are loaded in 200ms or less (or more), but sometimes (I cannot say when, because it's randomly and its NOT after the recycling) they need up to 2 minutes or more.

我试图窥发现问题。它显示是这样的:

I tried glimpse to find the problem. It shows something like:

在ASP.NET开始请求:121456ms(这是随机) 过滤器:2毫秒 控制器:26ms 正文:298ms 在ASP.NET结束请求:0毫秒

这就像一个要求堆放,我不知道。

It's like a request stacking, I don't know.

编辑:

所以,我已经删除了整个MVC站点地​​图提供者,但假体性能比较的问题仍然在这里。

So I've removed the whole MVC SiteMap Provider but the phantom perfomance issue was still here.

然后我检查IIS配置,发现该程序池是网络服务,而不是ApplicationPoolIdentity(其他MVC解决方案上ApplicationPoolIdentity运行),现在它似乎更快和以前一样(页面加载< 50毫秒)!如果问题仍然存在,我会写在这个线程。

Then I've checked the IIS Configuration and noticed that the AppPool was a NetworkService instead of ApplicationPoolIdentity (the other MVC solutions run on ApplicationPoolIdentity) and now it seems even faster as before (page loads < 50ms)! If the problem still occurs I'll write in this thread.

推荐答案

我对一个MVC3项目非常类似的问题,有点类似的架构,以你所描述的上述内容。我们的问题竟然是绑在MVCSitemapProvider。我会找我的笔记,以什么具体的问题是,但我们发现,如果我们禁用地图创建菜单,只是作为一个测试,一切都是快如闪电,那么当我们打开了后面的会很慢。

I had a very similar issue on an MVC3 project with a somewhat similar architecture to what you're describing above. Our issue turned out to be tied to the MVCSitemapProvider. I will look for my notes as to what the specific issue was, but we found that if we disabled the SiteMap creating the menus, just as a test, everything was lightning fast, then when we turned that back on it would get slow.

我会建议为调试这一问题的下一个步骤。

I would recommend that as a next step for debugging the issue.

好吧,我跟我的同事从项目之一,我现在回忆起来。有几个问题。首先,MVC的站点地图提供者吞下所有的异常;这并不完全是坏,但确实使故障排除困难。我们发现,造成两个略有不同的问题,两者都能引起经济放缓两种不同的情况。首先,我不认为你_Layout.cshtml或任何布局文件,要包括调用提供程序生成您的菜单,也许面包也是如此。

Okay, I talked to one of my co-workers from the project and I recall now. There are a couple problems. First of all, the MVC Sitemap Provider swallows all of its exceptions; this is not entirely bad but does make trouble-shooting difficult. We found two different scenarios that caused two slightly different issues, both causing a slowdown. First of all I do assume that in your _Layout.cshtml or whatever layout file, you are including a call to the provider to generate your menu and perhaps breadcrumbs as well.

如果您有在网站地图还没有定义任何时候你去到该页面控制器动作,企图生成菜单和面包屑异常后抛出异常,你永远也看不到他们。这是非常昂贵的,减缓该网页了。 如果您在您的站点地图中定义的节点指向的拼写错误,或根本就不存在一个控制器动作,每一次网站地图试图渲染菜单和/或面包屑,就抛出并吞下许多例外,为每一个页面。

我们曾与地图这两个和其他的问题,因为,我真的建议你淘sitemap文件,并确保你正在重新presenting中有你所有的控制器动作,那你没有任何节点定义不正确。如果你不能完全确定,可能要甚至把一些断点在网站地图code和步骤,通过它,看它是否抛出你的异常,然后向后跟踪从那里。

Because of these two and other issues we had with the sitemap, I would really recommend scouring your sitemap file and making sure that you are representing all your controller actions within there, and that you don't have any nodes incorrectly defined. If you cannot be entirely sure, you may want to even put some breakpoints in the sitemap code and step through it to see if it's throwing exceptions for you and then trace backwards from there.