在Inproc模式下具有页面只读的会话锁争用 [英] Session Lock Contention with Page Readonly in Inproc Mode

查看:55
本文介绍了在Inproc模式下具有页面只读的会话锁争用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近发现,当您将页面设置为只读会话并且您正在使用inproc(在内存中)会话存储时,该会话仍可在该页面上写入,而并非真正的只读.进程外会话存储确实会尊重只读设置.

I recently discovered that when you have a page set to session readonly and you are using inproc (in memory) session storage, the session is still writable on that page and is not truly read only. Out of process session storage does respect the readonly setting.

当页面设置为只读并使用Inproc模式时,您是否仍然受益于没有会话锁争用?在只读和inproc中时,具有相同会话ID的多个同时请求是否必须等待会话锁释放?

Do you still get the benefit of having no session lock contention when a page is set to readonly and using inproc mode? Will multiple simultaneous requests with the same session Id have to wait for the session lock to release when in readonly and inproc?

推荐答案

BuzzAnn,

Microsoft关于此主题的文档表明,将页面级会话状态模式设置为只读"应该可以防止同时写入写入会话状态信息的尝试(它们将排队并按顺序处理),但将允许多个读者.请参阅同步访问会话状态"部分:

Microsoft's documentation on the topic indicates that setting your page-level session state mode to "ReadOnly" should safeguard you against concurrent attempts to write session state information (they'll queue and be handled serially), but multiple readers will be allowed. See the "Synchronizing Access to the Session State" section:

http://msdn.microsoft.com/en-us/library/aa479041.aspx

当页面的 EnableSessionState 属性设置为"ReadOnly"时,每个页面请求都会尝试使读者锁定状态信息.在标准ReaderWriterLock语义中,任何数量的阅读器都可以并发访问受保护的信息.但是,任何达到写作者锁定的请求(例如,通过将 EnableSessionState 设置为"true"),将阻止写读取会话状态信息,直到请求保持作家锁完成.

When the EnableSessionState property for a page is set to "ReadOnly," each page request attempts to get a reader lock on the state information. In standard ReaderWriterLock semantics, any number of readers can have concurrent access to the information being protected. Any request that achieves a writer lock (e.g., through EnableSessionState being set to "true"), though, will block writes and reads on the session state information until the request holding the writer lock completes.

只要您想做的就是在 EnableSessionState 设置为"ReadOnly"的情况下从页面中读取会话状态信息,所有读取请求将继续进行而不会阻塞.但是,如果您尝试编写,则文档尚不清楚实际会发生什么.假设使用ReaderWriterLock来同步访问,我想您将不会受到覆盖,竞争条件和其他非同步访问问题的保护.

As long as all you're trying to do is read session state information from your pages while they have EnableSessionState set to "ReadOnly," all read requests will proceed without blocking. If you attempt to write, though, the documentation isn't clear about what will actually happen. Assuming a ReaderWriterLock is all that's being used to synchronize access, my guess is that you won't be protected against overwrites, race conditions, and other non-synchronized access problems.

如果您要尝试写入会话状态,请确保将 EnableSessionState 设置为"true",以确保获得写入器锁定并根据需要进行同步.

If you're going to attempt to write to session state, be sure to set EnableSessionState to "true" to ensure that a writer lock is achieved and synchronization occurs as is needed.

我希望这会有所帮助!

这篇关于在Inproc模式下具有页面只读的会话锁争用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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