我刚刚发现为什么所有ASP.Net网站是缓慢的,而我试图找出如何对待它 [英] I just discovered why all ASP.Net websites are slow, and I am trying to work out what to do about it

查看:107
本文介绍了我刚刚发现为什么所有ASP.Net网站是缓慢的,而我试图找出如何对待它的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚发现,在ASP.Net Web应用程序的每个请求获得在请求开始会话的锁,然后将其释放在请求结束!

I just discovered that every request in an ASP.Net web application gets a Session lock at the beginning of a request, and then releases it at the end of the request!

在情况下这种影响是失去了你,因为这是我在第一,这基本上意味着以下内容:

In case the implications of this are lost on you, as it was for me at first, this basically means the following:


  • 每当一个ASP.Net网页花费很长的时间来加载(可能是由于一个缓慢的数据库调用或其他),并且用户决定他们想要导航到不同的页面,因为他们厌倦了等待,不能!在ASP.Net会话锁定强制新的页面请求等到原始请求已经完成了它的极为缓慢负荷。 Arrrgh。

  • Anytime an ASP.Net webpage is taking a long time to load (maybe due to a slow database call or whatever), and the user decides they want to navigate to a different page because they are tired of waiting, THEY CAN'T! The ASP.Net session lock forces the new page request to wait until the original request has finished its painfully slow load. Arrrgh.

每当一个UpdatePanel加载速度慢,和用户决定在UpdatePanel完成更新......他们无法之前导航到不同的页面!该ASP.net会话锁定强制新的页面请求等到原始请求已经完成了它的极为缓慢负荷。双Arrrgh!

Anytime an UpdatePanel is loading slowly, and the user decides to navigate to a different page before the UpdatePanel has finished updating... THEY CAN'T! The ASP.net session lock forces the new page request to wait until the original request has finished its painfully slow load. Double Arrrgh!

那么有什么选择呢?到目前为止,我想出了:

So what are the options? So far I have come up with:


  • 实现自定义SessionStateDataStore,这ASP.Net支持。我还没有发现太多那里复制,它似乎有点高风险,容易陷入困境。

  • 跟踪正在进行的所有请求,并且如果请求来自同一个用户进来,取消了原有的请求。似乎有点极端,但它的工作(我认为)。

  • 请不要使用Session!当我需要某种状态的用户,我可以只使用缓存来代替,并在认证的用户名,或者一些这样的事情关键项目。又似乎有点极端。

我真的无法相信ASP.Net微软团队将在4.0版本已经留下了这样的框架,一个巨大的性能瓶颈!我失去了一些东西明显?这将有多难是使用ThreadSafe的集合会话?

I really can't believe that the ASP.Net Microsoft team would have left such a huge performance bottleneck in the framework at version 4.0! Am I missing something obvious? How hard would it be to use a ThreadSafe collection for the Session?

推荐答案

OK,这么大的道具乔尔穆勒对他的所有输入。我最终的解决方案是使用这个MSDN文章的最后详细介绍了自定义SessionStateModule:

OK, so big Props to Joel Muller for all his input. My ultimate solution was to use the Custom SessionStateModule detailed at the end of this MSDN article:

<一个href=\"http://msdn.microsoft.com/en-us/library/system.web.sessionstate.sessionstateutility.aspx\">http://msdn.microsoft.com/en-us/library/system.web.sessionstate.sessionstateutility.aspx

这是:


  • 非常快速实施(实际上似乎比上年提供商路线更容易)

  • 用过很多标准的ASP.Net会话处理开箱即用的(通过SessionStateUtility类)

这方面取得了巨大的差异,以snapiness我们的应用程序的感觉。我仍然无法相信ASP.Net会话的自定义实现锁定整个请求的会话。这增加了低迷的如此巨大数额的网站。从网上的研究,我不得不做的量来看(和对话有几个真正经历ASP.Net开发者),很多人都经历过这个问题,但很少有人曾经到了事业的底部。也许我会写信给斯科特谷...

This has made a HUGE difference to the feeling of "snapiness" to our application. I still can't believe the custom implementation of ASP.Net Session locks the session for the whole request. This adds such a huge amount of sluggishness to websites. Judging from the amount of online research I had to do (and conversations with several really experienced ASP.Net developers), a lot of people have experienced this issue, but very few people have ever got to the bottom of the cause. Maybe I will write a letter to Scott Gu...

我希望这有助于一些人在那里!

I hope this helps a few people out there!

这篇关于我刚刚发现为什么所有ASP.Net网站是缓慢的,而我试图找出如何对待它的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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