为什么页面处理的AspNetSessionData阶段由20多秒延迟我的网页? [英] Why is the AspNetSessionData stage of page processing delaying my page by 20+ seconds?

查看:258
本文介绍了为什么页面处理的AspNetSessionData阶段由20多秒延迟我的网页?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用ASP.NET以是InProc会话处理的Web应用程序。通常情况下,一切工作正常,但几百个请求,每天显著更长的时间比正常运行。在IIS日志,我可以看到,这些页面(通常需要2-5秒的时间跑到)是为20多秒的运行。

I have a web application that uses ASP.NET with "InProc" session handling. Normally, everything works fine, but a few hundred requests each day take significantly longer to run than normal. In the IIS logs, I can see that these pages (which usually require 2-5 seconds to run) are running for 20+ seconds.

我启用失败请求以详细模式追踪,发现延迟在AspNetSessionData部分发生。在下面所示的例子中,有AspNetSessionDataBegin和AspNetSessionDataEnd之间39秒的差距。

I enabled Failed Request Tracing in Verbose mode, and found that the delay is happening in the AspNetSessionData section. In the example shown below, there was a 39-second gap between AspNetSessionDataBegin and AspNetSessionDataEnd.

我不知道下一步该怎么做。我找不到任何理由拖延,我找不到可以启用告诉我这里发生了什么更多的日志记录功能。有谁知道为什么发生这种情况,或者有额外的步骤,任何建议,我可以采取发现问题?

I'm not sure what to do next. I can't find any reason for this delay, and I can't find any more logging features that could be enabled to tell me what's happening here. Does anyone know why this is happening, or have any suggestions for additional steps I can take to find the problem?

我的应用程序通常存储在会话为每个用户1-5MB,大多是缓存数据的搜索。该服务器有足够的可用内存,并且只运行约50的用户。

My app usually stores 1-5MB in session for each user, mostly cached data for searches. The server has plenty of available memory, and only runs about 50 users.

推荐答案

它可以通过为会话状态的锁争用而引起的。看看MSDN的 ASP.NET会话状态概述末段。参见<一个href=\"http://odeto$c$c.com/Blogs/scott/archive/2006/05/21/session-state-uses-a-reader-writer-lock.aspx\"相对=nofollow> K。斯科特·艾伦的帮助的帖子关于这个问题的。

It could be caused by lock contention for the session state. Take a look at the last paragraph of MSDN's ASP.NET Session State Overview. See also K. Scott Allen's helpful post on this subject.

如果一个页面都被注解的EnableSessionState =真(或继承的web.config默认值),则该页面的所有请求都将获得对会话状态写锁。即使他们没有获得一个写锁 - - 使用会话状态的所有其他请求。被阻塞,直到该请求完成

If a page is annotated with EnableSessionState="True" (or inherits the web.config default), then all requests for that page will acquire a write lock on the session state. All other requests that use session state -- even if they do not acquire a write lock -- are blocked until that request finishes.

如果一个页面用的EnableSessionState =只读注明,那么页面将无法获取写锁,所以不会阻止其他请求。 (虽然它可能由其它请求持有写入锁被阻止。)

If a page is annotated with EnableSessionState="ReadOnly", then the page will not acquire a write lock and so will not block other requests. (Though it may be blocked by another request holding the write lock.)

要消除这种锁争用,您可能希望实现自己的[更细粒度]周围的 HttpContext.Cache 对象或静态的 WeakReference的秒。后者可能是更有效的。 (见第理查德Kiessig 超快速ASP.NET 的118-122)。

To eliminate this lock contention, you may want to implement your own [finer grained] locking around the HttpContext.Cache object or static WeakReferences. The latter is probably more efficient. (See pp. 118-122 of Ultra-Fast ASP.NET by Richard Kiessig.)

这篇关于为什么页面处理的AspNetSessionData阶段由20多秒延迟我的网页?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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