网络场中的 ASP.NET MVC2 - 高流量时页面加载缓慢

发布于 2024-12-08 03:11:54 字数 558 浏览 0 评论 0原文

我们有一个用 MVC2 + Linq2SQL + MS SQL SERVER 2008 编写的 Web 应用程序,托管在 Web 场上。几乎像 stackoverflow.com

我们有 4 x IIS7 + 1 SQL SERVER 2008 通过 MS NLB 进行负载平衡

静态内容由外部缓存提供程序 - Akamai 进行缓存,这减少了 86% 的请求。

每个 Web 服务器都有 32 GB RAM 和 4 个四核 CPU,因此前端有 64 个核心。

我们在表中保存会话状态。

它在中等流量(页面加载 = 0.2 秒)下工作得很好,但该公司会投放电视广告,在这些广告期间,流量会在 20-30 秒内达到 20,000 个用户。

此时页面速度减慢至 8 - 10 秒。然而,在任何机器上,CPU 和内存的使用率甚至都没有达到 40%。

数据中心的带宽没有达到其极限的一半。

速度慢的页面仅从 1-2 个表中最多 10 条记录的简单 SELECT 生成数据。

显然某个地方存在瓶颈,并试图找出哪里。

有人对我在哪里寻找问题有任何建议吗?

We have a web application written in MVC2 + Linq2SQL + MS SQL SERVER 2008 hosted on the web farm. Almost like stackoverflow.com

We have 4 x IIS7 + 1 SQL SERVER 2008 load balanced with MS NLB

Static content is cached by external cache provider - Akamai, which reduces 86% of the requests.

Each web server has 32 GB of RAM and 4 x quad core CPUs so there are 64 cores on the front-end.

We save a session state in tables.

It works prefectly with medium traffic (page load = 0.2 s) but the company does the tv ads and during those ads the traffic hits up to 20,000 users within 20-30 seconds.

In this moment the page slows down to 8 - 10 seconds. However, the usage of CPU's and the memory doesn't even arrive to 40% on any machine.

The bandwidth of the data centre does not arrive to the half of its limits.

Pages which are slow generate data from simple SELECTs of maximum 10 records from 1-2 tables only.

Clearly there is a bottleneck somewhere and trying to figure out where.

Anyone has any advice for me where to look for a problem?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

蒗幽 2024-12-15 03:11:54

我前段时间发现了这个问题,但没有时间在这里发布。我几乎尝试了所有我能想到的事情:索引、优化sql、监控磁盘I/O、修改代码。以上都没有解决我的问题。我从局域网上的 2 个工作站运行网络压力测试,我可以在几秒钟内冻结整个页面!在运行测试时我注意到一些奇怪的事情。我创建了一个单独的控制器进行测试,并放置了两种方法。两者都做同样的事情:向我们的数据库服务器请求相同的数据。

Action A)

public ActionResult Index(){
var model = new SomeModel();
// Get data
....
return View(model);
}

Action B)

public ActionResult Index() {
 var model = new SomeModel();
// Get data
....
return View("Index",model);
}

页面加载差异:

A) ~ 297 ms

B) ~ 39.47 s

这仅在高并发时出现,其他情况都很好。
似乎 MVC2 库中默认视图的搜索导致了问题,因为一旦指定它,一切都会很好。

我在我的博客上描述了它:

我已将其发布在 codeplex 上的 asp.net 问题跟踪器中,但尚未有人评论/回复。

http://aspnet.codeplex.com/workitem/9396

I found the problem sometime ago but didn't have a time to post it here. I have tried almost every possible thing I could think of: indexes, optimizing sql, monitoring disk i/o, revising the code. Nothing of the above solved my problem. I run the web stress test from 2 workstations on our lan and I could freeze the whole page in seconds! While running tests I have noticed something odd. I created a separate controller for testing and I put 2 methods. Both doing the same thing: asking for the same data our database server.

Action A)

public ActionResult Index(){
var model = new SomeModel();
// Get data
....
return View(model);
}

Action B)

public ActionResult Index() {
 var model = new SomeModel();
// Get data
....
return View("Index",model);
}

The difference in page load:

A) ~ 297 ms

B) ~ 39.47 s

This occurs only during the high concurrency, otherwise is fine.
Seems like the search of default View in MVC2 library is causing the problem as once it is specified it all works great.

I have described it on my blog:

http://arturito.net/2011/10/24/asp-net-mvc2-in-the-web-farm-slow-page-load-with-high-traffic-where-is-the-bottleneck/

I have posted it in Issue Tracker of asp.net on codeplex but nobody has commented/responded to it yet.

http://aspnet.codeplex.com/workitem/9396

攒眉千度 2024-12-15 03:11:54

对于一些较小的性能优势,您可以尝试 Rico Mariani 在 http://blogs.msdn.com/b/ricom/archive/2007/06/22/dlinq-linq-to-sql-performance-part-1.aspx。具体尝试使用 CompiledQuery 并关闭仅显示对象的更改跟踪。

For some smaller performance benefits, you may try some of the tweaks Rico Mariani mentions at http://blogs.msdn.com/b/ricom/archive/2007/06/22/dlinq-linq-to-sql-performance-part-1.aspx. Specifically try using CompiledQuery and turning off change tracking for display only objects.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文