开发者

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

开发者 https://www.devze.com 2022-12-19 11:15 出处:网络
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

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开发者_如何学JAVA found any information on how long this lock time-out is, or how to change it.


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".


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消