How to set the ASP.NET SessionState read-write LOCK time-out?

谁都会走 提交于 2019-12-12 12:14:44

问题


I have a WCF web service that uses ASP.NET session state. WCF sets a read-write lock on the session for every request. What this means is that my web service can only process one request at a time per user, which hurts perceived performance of our AJAX application.

So I'm trying to find a way to get around this limitation.

  • Using a read-only lock (which then allows concurrent access to the session) isn't supported by WCF.
  • I haven't found a way to release the read-write lock manually during processing of a request
  • So now I'm thinking that there may be some way to set the read-write lock timeout to some very short interval, in order that waiting requests don't need to wait very long. See the below part in bold.

From MSDN: http://msdn.microsoft.com/en-us/library/ms178581.aspx

"If two concurrent requests are made for the same session, the first request gets exclusive access to the session information. The second request executes only after the first request is finished. (The second session can also get access if the exclusive lock on the information is freed because the first request exceeds the lock time-out.) If the EnableSessionState value in the @ Page directive is set to ReadOnly, a request for the read-only session information does not result in an exclusive lock on the session data."

...But I haven't found any information on how long this lock time-out is, or how to change it.


回答1:


Has anyone tried using SQLSessionStateProvider and modifying the SPs? I did this in dev and seems to get around the locking issues but not sure if it has any side-effects. Basically what I did was change the 3 SPs which obtain Exclusive locks so that the Lock column is always set to 0.




回答2:


I can tell you that httpRuntime execution timeout controls this lock time, however, the documentation for this field states that the thread should be terminated at this point. I know from experience that this thread is not terminated and will eventually return data, but a new thread is spawned to handle requests in the queue.

By default this value is 110 seconds after 2.0 asp, before that it is 90 seconds. I would be concerned about this behavior changing in the future and being "fixed".



来源:https://stackoverflow.com/questions/2204560/how-to-set-the-asp-net-sessionstate-read-write-lock-time-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!